Results 1 to 8 of 8
- 11-21-2010, 01:33 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Compilation Error in basic java class
Hello,
I am newbie. And, I have developed following java classes. But the child class is results in error. Below is step by step event. What am I doing wrong?
Step 1. Created a compiled class Shirt(parent). No issues
Step 2. Child class results in compilation errorJava Code:public class Shirt { public int shirtID =0; public String description = "description required"; // color codes public char colorCode = 'U'; public double price = 0.0; public int quantityInStock = 0; // methods public void displayShirtInformation() { System.out.println("Shirt ID: " + shirtID); System.out.println("Shirt description:" + description); System.out.println("Color Code:" + colorCode); System.out.println("Shirt price: " + price); System.out.println("Quantity in Stock :" + quantityInStock); } // end of method } // end of class
Step 3. Error show belowJava Code:public class ShirtTest{ public static void main (Strings args[]) { Shirt myShirt; myShirt = new Shirt(); myShirt.displayShirtInformation(); } }
Thanks D,Java Code:C:\Java>javac ShirtTest.java ShirtTest.java:3: cannot find symbol symbol : class Strings location: class ShirtTest public static void main (Strings args[]) { ^ ShirtTest.java:4: cannot find symbol symbol : class Shirt location: class ShirtTest Shirt myShirt; ^ ShirtTest.java:5: cannot find symbol symbol : class Shirt location: class ShirtTest myShirt = new Shirt(); ^ 3 errors
-
Fix the first error: Strings, and then let us know what happens.
- 11-21-2010, 06:45 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
About this,
Java Code:public static void main (Strings args[]) {
- 11-21-2010, 09:47 PM #4
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Error
Thank you I have corrected as per your advice. Now the code looks like below
At the time of compilng above class, I still get following ERROR. :(Java Code:public class ShirtTest{ public static void main (String args[]) { Shirt myShirt; myShirt = new Shirt(); myShirt.displayShirtInformation(); } }
Thanks,Java Code:C:\Ruchir\Java>javac ShirtTest.java ShirtTest.java:4: cannot find symbol symbol : class shirt location: class ShirtTest shirt myShirt; ^ ShirtTest.java:5: cannot find symbol symbol : class shirt location: class ShirtTest myShirt = new shirt(); ^ 2 errors
D
-
The messages are telling you clearly what needs to be fixed. Spelling and capitalization are important.
- 11-21-2010, 10:18 PM #6
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Error
Oh yes. I have the parent class with same namin conventions. I mean, I now have Shirt class as 'S' capital. But still I am getting following error.
And the actual code object is :Java Code:C:\Java>javac ShirtTest.java ShirtTest.java:4: cannot find symbol symbol : class Shirt location: class ShirtTest Shirt myShirt; ^ ShirtTest.java:5: cannot find symbol symbol : class Shirt location: class ShirtTest myShirt = new Shirt(); ^ 2 errors
The parent Shirt class:Java Code:public class ShirtTest{ public static void main (String args[]) { Shirt myShirt; myShirt = new Shirt(); myShirt.displayShirtInformation(); } }
Java Code:public class Shirt { public int shirtID =0; public String description = "description required"; // color codes public char colorCode = 'U'; public double price = 0.0; public int quantityInStock = 0; // methods public void displayShirtInformation() { System.out.println("Shirt ID: " + shirtID); System.out.println("Shirt description:" + description); System.out.println("Color Code:" + colorCode); System.out.println("Shirt price: " + price); System.out.println("Quantity in Stock :" + quantityInStock); } // end of method } // end of class
-
Hm, I'm at a loss to explain this now. You've compiled the Shirt class without problem, correct?
- 11-21-2010, 11:23 PM #8
Member
- Join Date
- Nov 2010
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem
By jcen in forum New To JavaReplies: 2Last Post: 11-06-2011, 04:40 PM -
Basic Java applet error, cant figure it out!
By alacn in forum Java AppletsReplies: 3Last Post: 08-03-2010, 06:25 PM -
bean compilation error
By technical_helps@yahoo.com in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 07-29-2009, 11:21 PM -
java.lang.Error: Unresolved compilation problems
By jon80 in forum New To JavaReplies: 0Last Post: 06-07-2009, 10:04 PM -
JAVA compilation error in UNIX
By satish kumar in forum Advanced JavaReplies: 9Last Post: 08-08-2008, 07:36 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks