• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot find symbol

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm assuming that you're getting the error at

In class Doggy, declare size as public -

That might solve it!
 
Marshal
Posts: 79261
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79261
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There appears to be no compiler error in the code posted. Read this FAQ.
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic