GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Need help with add() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with add() method" Watch "Need help with add() method" New topic
Author

Need help with add() method

Akane Tanaban
Greenhorn

Joined: May 17, 2004
Posts: 4
Hello,
I am a beginner taking my first java class, and my teacher posted this
example for us to compile and run. However, it doesn't work, and he is slow to respond to my question. Homework is based on extending this program, but it's hard to even begin if the example program doesn't work.

Any kind hearted soul willing to help me?
Thanks.

Here is the code. The error message follows.

// Begin code


// End of code

/*---------------Error message-----------------

-----------------End of error message---------*/

[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ May 17, 2004: Message edited by: Dirk Schreckmann ]
Ben Buchli
Ranch Hand

Joined: Mar 26, 2004
Posts: 83
hi,
when i run your code it works... what version jre version are you running?

is this error message really from when you run the code posted?? it refers to a class called Applet that extends Applet. Was your AdderButton class once called Applet?
[ May 17, 2004: Message edited by: Ben Buchli ]
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Compiles fine for me. I suspect that you have some other class in your project/package that causes the problem. I added class



And now I see the same list of errors that you posted, including the "cyclical inheritance", which is the key.
Akane Tanaban
Greenhorn

Joined: May 17, 2004
Posts: 4
I am using java2 sdk 1.4.1, standard edition.
Also, I am using this software called Sun One Studio 4 update 1, Community Edition as the graphic interface -- I guess that's what you call it.
It has a text editor and compiler all there easy to use.
I tried to compile it from the command window by using javac as well, and it gave me the same errors.

In my confusion, I did accidentally name it Applet before, but then I changed the name and saved it and everything, and it stills gives that error. I cut and pasted the program several times into a new file, but that error still comes up like that. If I take the 'extends Applet' part out, it seems to go away.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
In my confusion, I did accidentally name it Applet before, but then I changed the name and saved it and everything, and it stills gives that error.

Search in your file system for file Applet.java and Applet.class, -- they may still be out there in the IDE disk cache, and your project may be tracking it.
Ben Buchli
Ranch Hand

Joined: Mar 26, 2004
Posts: 83
if the problem still persists, you might want to compile a new .class file.
if that doesnt help, restart the ide and make sure there's no hanging vm.

hope that helps
Akane Tanaban
Greenhorn

Joined: May 17, 2004
Posts: 4
Thank you for your help.
The Applet.java file was still in the same folder as the AdderButton.java file. When I tried to delete it, to my surprise it stated that it was being used, and that I needed to close it in order to delete it. At that time, only the AdderButton.java file was open.

So I guess it was somehow finding it.

Once I closed everything, I was able to delete the Applet.java file, and the AdderButton.java file compiled just fine!

Thank you, thank you, thank you
 
GeeCON Prague 2014
 
subject: Need help with add() method