This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot find symbol" Watch "cannot find symbol" New topic
Author

cannot find symbol

Naga Nagesh
Greenhorn

Joined: Sep 29, 2008
Posts: 1
Hi, I am getting this error: "cannot find symbol"

These are the classes I wrote...

public class DogTestDrive
{
public static void main(String[] args)
{
Doggy d = new Doggy();
d.size = 40;
d.bark();
}

}

.....
public class Doggy
{
int size;
String breed;
String name;
void bark()
{
if(size > 60)
{
System.out.println("Ruff Ruff");
}
else
{
System.out.println("Ding Ding");
}
}
}

Please help..I am trying to get my hands on java..Thanks in advance.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

"Nagesh B",

Please read your private messages regarding an important announcement.

Thank you,

Rob


Also, please Use Code Tags. And finally, Tell The Details. What is the exact message? Which symbol can't it find?

I've just tried to compile the code you've posted here, and there was no problem at all.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

The error message tells you exactly what symbol it cannot find. that's a big clue into solving your problem. a quick eyeball of your code doesn't have anything pop out as to the problem.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
I'm assuming that you're getting the error at

In class Doggy, declare size as public -

That might solve it!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37956
    
  22
Unlikely that is the problem if the two are in the same folder. Besides it is bad design to have public fields, or to set them like d.size = 40;
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37956
    
  22
There appears to be no compiler error in the code posted. Read this FAQ.
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Originally posted by Campbell Ritchie:
Unlikely that is the problem if the two are in the same folder. Besides it is bad design to have public fields, or to set them like d.size = 40;


Yup. Recommend adding a getter and setter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot find symbol
 
Similar Threads
Wrong coding
Quick question about instance variables
Class dog problems
class and testclass
Doubt about private modifier