File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes class and testclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "class and testclass" Watch "class and testclass" New topic
Author

class and testclass

Besjamain Greenaway
Ranch Hand

Joined: Dec 21, 2007
Posts: 45
Hello :-)

I am working throught the head first book, and the subject now is about making a class and testclass. I get the impression that these two files should be seperate, so with one of the exercises I had to do I did;



and the testclass;



When I run it, it seems to compile, but then an error emerges;

DrumkitTestDrive.java:13: cannot find symbol
symbol : method playsnare()
location: class Drumkit
d.playsnare();
^

there's another one that says java:10:.

I've looked on the internet, and get the impression that something is not installed to make it work. Is this true?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18120
    
  39

DrumkitTestDrive.java:13: cannot find symbol
symbol : method playsnare()
location: class Drumkit
d.playsnare();


Java is case sensitive. The method is playSnare(), with a capital S. The compiler can't find one with the lower case s.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Besjamain Greenaway
Ranch Hand

Joined: Dec 21, 2007
Posts: 45
Thanks a lot! But wow, is that emberassing! Just a simple syntax prob
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
We have all made that sort of mistake. You could have written play Snare() instead, which has another error in.

Please don't write "if (d.snare == true) . . ." Write "if(d.snare) . . ." The "== true" is unnecessary. Try it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class and testclass
 
Similar Threads
Wrong coding
Boolean question
Method help: how does this work?
Error: Exeption in thread "main" java.lang.NoSuchMethodError: main
Head First Java Beginnner's Question