Please check the package under which you created these classes. The compiler is 
lookiing for the package 'myFood' which does not exist. Ensure that these 
classes are created under the food package directory. 

Steve 
----- Original Message ----- 
From: "yongchun gao" <[email protected]> 
To: [email protected] 
Sent: Monday, September 28, 2009 3:44:30 AM GMT +01:00 West Central Africa 
Subject: [java programming] help for Lab-1003 

Hello, 

Can someone help me to figure out what the problem is? 

I have two classes: Food and FoodMain as below. 

the error I got is: 
----------------------------------------------------------------------- 
package myFood does not exist 
<identifier> expected 
illegal start of type 

----------------------------------------------------------------------- 
Food.java 

package foodpackage.fruitpackage; 

public class Food 
{ 

// Declare instance variables. 
private String name; 

public Food(){ 
} 

public Food (String foodName) 
{ 
name = foodName; 
} 

public String getName() 
{ 
return name; 
} 

public void setName(String temp ) 
{ 
name =temp; 
} 

} 



FoodMain.java 

package foodpackage.fruitpackage; 

public class FoodMain 
{ 
Food myFood = new Food(); 

myFood.setName("dsfa"); 

//System.out.println(""); 
} 



Thanks 




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to