I worked on it and got it to run! Thanks so much for your help!
When I get to the next step of my assignment can I post any questions under this same thread or should I start a new one?
ITQUEST...
User Profile
Collapse
-
I am not sure if I understand. I have changed the code in the beginning to look like this:
// Product2 class
import java.util.*;
public static void main (String args[])
Product2 p = new Product2();
class Product2 implements Comparable {
private String title; // class variable stores the item title
private long number; // class variable stores...Leave a comment:
-
Yes I believe so. I changed that part of the code to read as this:
public int compareTo (Object o) {
Product2 p = null;
try {
p = (Product2)o;
}
catch(ClassCast Exception cE) {
cE.printStackTr ace();
}
return title.compareTo (p.getItemTitle ());
}
And tried to run it. It gives me the error: Exception in Thread "Main" java lang. NoSuchMethodErr or:...Leave a comment:
-
Yes this is my latest version of Product2. I do not see a getItemName().. .where do you see that? I guess I have been working so long I am getting confused. Do you see the error in my posted code?
Thanks for your help! ITQUEST...Leave a comment:
-
Inventory Java Project Help
I am on the second step of my Inventory Project and can properly run my Inventory2.java file but not my Product2.java file. I get the following error: 71:cannot find symbol, symbol: method getItemTitle() location: class Product
returntitle.com pareTo(p.getIte mTitle());
^
Here is my code:
...Code:// Product2 class import java.util.*; class Product2 implements
-
Thanks to both of you for the explanations. They made sense to me and I was able to correctly complete my assignment because of this.
Thanks Again!
ITQUESTLeave a comment:
-
.class vs. .java
The moderator posted this in another thread:
(I am starting a new one not to confuse the other subject at hand)
".java classes are compiled to into .class files. If you have a .java file called Product.java, when you compile it a .class is created for every class in the file Product.java if there are no errors. In this case you are getting this error because there is no class file called Product.class so you must compile... -
I run it and get the following error:
NoClassDefFound Error: Product
Any suggestions?...Leave a comment:
-
Do you post the first half as your .java and the second as your .class to get it to run? I understand how you have it written. I can read the material and understand it when I see it, but putting the two together is the challenge for me.
I have to say that all of the classes so far have been fine, but this one is bad. Do you mind me asking questions along the way or will you leave this forum after you complete the course?
...Leave a comment:
-
Me again...
I am also wondering how to set up a class. I get how to establish the Java file but the class thing has me confused. What is the difference? I guess I have just been getting by until now, but I can't seem to get it right!
ITQUEST...Leave a comment:
-
Stevedub,
Looks like I am in the same class you are but only in Week 5. I am completely lost and the teacher is NO help!
Can you offer any advice for the Wk 5 Checkpoint? It is the Inventory Program Part 1.
ITQUEST...Leave a comment:
No activity results to display
Show More
Leave a comment: