cannot find symbol?......wats happening???
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Never try to be a hard-worker. Be a smart-worker.
My Blog
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Here are the errors im getting.....
>javac Human.java
Human.java:11: cannot find symbol
symbol : class Head
location: class Human
public Head myHead;
^
Human.java:12: cannot find symbol
symbol : class Arm
location: class Human
public Arm[] myArms = new Arm[2];
^
Human.java:13: cannot find symbol
symbol : class Leg
location: class Human
public Leg[] myLegs = new Leg[2];
^
Human.java:12: cannot find symbol
symbol : class Arm
location: class Human
public Arm[] myArms = new Arm[2];
^
Human.java:13: cannot find symbol
symbol : class Leg
location: class Human
public Leg[] myLegs = new Leg[2];
^
Human.java:27: cannot find symbol
symbol : class Head
location: class Human
myHead = new Head();
^
Human.java:28: cannot find symbol
symbol : class Arm
location: class Human
myArms[0] = new Arm("RightArm");
^
Human.java:29: cannot find symbol
symbol : class Arm
location: class Human
myArms[1] = new Arm("LeftArm");
^
Human.java:30: cannot find symbol
symbol : class Leg
location: class Human
myLegs[0] = new Leg("RightLeg");
^
Human.java:31: cannot find symbol
symbol : class Leg
location: class Human
myLegs[1] = new Leg("LeftLeg");
^
10 errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
javac -cp "C:\Program Files\Java\jre1.5.0_04\bin" <YourClass>.java
And the problem may be due to the classpath error. Check your classpath.
And do readthis article which might be clear you about the error. You may also find some good one's if you google "cannot find symbol error in java".
Never try to be a hard-worker. Be a smart-worker.
My Blog
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Rajkumar balakrishnan:
Try compile with this command
javac -cp "C:\Program Files\Java\jre1.5.0_04\bin" <YourClass>.java
No, don't use that command. Don't put any files in the bin folder, which should be reserved for classes from the Java API. Older versions of Java had their bin folder in the classpath, but that is no longer necessary.Which folder have you got the Head Arm and Leg classes in?
Do they have a package declaration? In which case you will have to import them. Otherwise, Rajkumar Balakrishnan's first suggestion, to make sure the Head Arm and Leg classes are in the correct folder, will probably sort out your problem.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
No, don't use that command. Don't put any files in the bin folder, which should be reserved for classes from the Java API. Older versions of Java had their bin folder in the classpath, but that is no longer necessary.
I just denote that for an example and not force him to compile what exactly i type here. Just use the classpath instead of a one which i used there.Like
javac -cp "Your Class Path" <YourClass>.java
Never try to be a hard-worker. Be a smart-worker.
My Blog
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I am developing a class to represent a Human. The head, arms and legs should be properties of the human and should be represented by separate objects. All of the objects should have at least three properties and one method. The head, arms and legs can only be constructed from within the same package. The human should include a walk method that uses the legs to actually move. In the main method of the human, I have created an instance of a human and set the properties so that it looks like somebody. Produce a UML class diagram that explains how the classes relate to each other. Assume that relations between Human and Arm or Leg are compositions. Be careful creating your constructor in Human class. Understand well what composition means.....
This is what iv come up with. After debugging got two errors now....din know Java was this hard. Been at it from morning.
And the errors.....
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
public Arm[] myArms=new Arm[2];
I am not sure what you exactly meant by this piece of code
public Leg[] myLegs = new Leg[2]();
Because []() were not put at successive places.
Never try to be a hard-worker. Be a smart-worker.
My Blog
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Rajkumar balakrishnan:
just change your code like this one.
Because []() were not put at successive places.
When i do that, i get this errors...
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
private Leg[] myLegs = new Leg[2]; and similar.
I presume you have the Leg Head and Arm classes already? You ought to test them first. Let's have a LegTest class . . . When you have run that class, you can see that the Leg is working. Similarly for Arm and Head.
The System.out.... l) bit calls the toString() method in the Leg object. If you haven't overridden toString() you will get something like Leg@1234abcd.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Never try to be a hard-worker. Be a smart-worker.
My Blog
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Rajkumar balakrishnan:
I agree with Campbell Ritchie.. Just do compile your Arms, Legs and whatever other classes you used here. Then try to compile it . It surely works. A cannot find symbol instead tell you that it can't find such a symbol or class or whatever is missing.
Hi all....
Thanks for your help guys...appreciate it. Here are the Human, Arm, Leg and Head classes. Tiz now working ok.
Human.java
class Head
class Arm
class Leg
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Campbell Ritchie:
Well done. Just one thing: make access to the Arm and Leg objects in the Human class private. You don't want outside code altering them while you're not watching.
Ok. i will and post tomorrow. Thanks
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by saidon conteh:
Ok. i will and post tomorrow. Thanks
question though. how can I use constructors to set properties of leg,head,arm classes?
| For my next trick, I'll need the help of a tiny ad ... The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










