Results 1 to 2 of 2
Thread: identifier expected error
- 04-27-2010, 06:56 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 1
- Rep Power
- 0
identifier expected error
Hi,
I am trying out some code to understand abstract class and package, but hitting an error. Here are the details:
I have the following classes:
Fruit.java
---------
package food;
public abstract class Fruit{
public abstract void eat();
}
Apple.java
----------
package food;
import food.Fruit;
public class Apple extends Fruit{
public void eat() {
System.out.println("I am eating an Apple");
}
}
Snack.java
-----------
package food;
public class Snack{
Apple myFruit = new Apple();
myFruit.eat();
}
I am compiling using the following command: javac -d /java/code/classes <filename>.java
I have added /java/code/classes to my CLASSPATH.
I have compiled Fruit.java and Apple.java successfully. But when I try to compile Snack.java, I get an <identifier expected> error on line 6.
What am I doing wrong? Thanks in advance for your help.
- 04-27-2010, 08:13 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Error:identifier expected(Help!)
By chhoton in forum New To JavaReplies: 8Last Post: 09-22-2009, 04:42 PM -
error"<identifier> expected" trough the use of interface
By parme in forum New To JavaReplies: 3Last Post: 12-05-2008, 08:34 PM -
getting identifier expected error . help me !
By victorkeath in forum New To JavaReplies: 3Last Post: 11-07-2008, 05:49 PM -
Identifier expected error
By vasu18 in forum New To JavaReplies: 1Last Post: 01-01-2008, 05:49 PM -
Error: <identifier> expected
By barney in forum AWT / SwingReplies: 2Last Post: 07-31-2007, 07:38 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks