title: Java <identifier> expected with writeObject()
body: <p>For a class assignment, I'm required to write an object to a file. Our professor gave us a section of code to complete this, but apparently it's wrong because I'm getting an error. Here's my code.</p>
  
  <pre><code>class InvMaintenance {
  
      //create an OutputStream to write data to a file
      FileOutputStream fos = new FileOutputStream(inven.dat);
      BufferedOutputStream bos = new BufferedOutputStream(fos);
      ObjectOutputStream oos = new ObjectOutputStream(bos);
  
      final long MAX_SIZE = 100; //constant for array length
      Inventory cInventory = new Inventory(MAX_SIZE); //instantiate Inventory object
      oos.writeObject(cInventory); //write initial Inventory to file  
      public static void main(String[] args) {
          //Output options
          /*  Inventory Maintenance
              1) Add Item
              2) Remove Item
              3) Sell Item
              4) Receive Item
              5) Display Inventory
              6) Quit
              Please Select NUMBER: */
  
          //switch on options
          //call appropriate method
  
          oos.writeObject(cInventory);
          oos.close();
      }
  }
  </code></pre>
  
  <p>My error is occuring on the line <code>oos.writeObject(cInventory);</code></p>
  
  <pre>
  Item.java:150: &lt;identifier&gt; expected
      oos.writeObject(cInventory);            //write initial Inventory to file   
                     ^
  Item.java:150: &lt;identifier&gt; expected
      oos.writeObject(cInventory);            //write initial Inventory to file   
                                ^
  2 errors
  </pre>
  
  <p>And yes, for some reason it's saying this is two separate errors that are... exactly the same.</p>
  
  <p>Any help debugging would be appreciated. What's wrong?</p>