aspose file tools*
The moose likes Beginning Java and the fly likes Homework Trouble: Not understood syntax error, Instance of a generic BST class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Homework Trouble: Not understood syntax error, Instance of a generic BST class" Watch "Homework Trouble: Not understood syntax error, Instance of a generic BST class" New topic
Author

Homework Trouble: Not understood syntax error, Instance of a generic BST class

Frank Harris
Greenhorn

Joined: Apr 07, 2010
Posts: 5
Hey folks, my Data Structures class has me creating a generic tree and filling it with a Comparable object known as SceneObject, compared by trig functions based on 4 ints.

If I had to guess where my problem lay, it would be in the declarative line for one of my classes.

First, the tree class: It shows no errors, which of course doesn't mean it's not where the problem lies. :-p



And here is the class that implements the tree class, creating a new tree known as Space. I have tried this for both the SceneObject class I created, as well as creating another tree of Integers. Same problem...When using a function defined in either class...for instance space.whatever, it starts off by not showing the Smart Insert options that you would expect to see when typing space. or temp., and when you enter in the function it gives the errors commented in the code below.



Thanks in advance for your advice!
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Frank:

For your last syntax error, compare line 60 of your first class, and line 12 of your second class. That should give you the reason.

John.
Frank Harris
Greenhorn

Joined: Apr 07, 2010
Posts: 5
Whoops...Good eye, but that was not the problem. I got a little confused there because I had been trying to use a similar function that probably wasn't camel-cased.

From what I can tell from research online, the error on line 8 of my SpaceTree class, Syntax error on token "temp", VariableDeclaratorId expected after this token, means that when the compiler looks to see what function this is referring to, it can't find one...it's as though it thinks I'm declaring a method right then and there.

Furthermore, it seems to be treating "temp," an instance of SceneObject declared above, as a datatype. Why on earth might that be?

I didn't quote the SceneObject code because I didn't want to clutter the message...in case it would be useful, I'll post it at the bottom of this message.

It should just be treated as an object class that implements Comparable, which as far as I can tell just means it needs to have a compareTo(SceneObject o) function of type int in it. It does, and it's public.

Showing it to my roommate, he thinks the errors in the SpaceTree class have something to do with a function improperly nested in another function instead of just out there in the class...but I have searched high and low for such a problem to no avail.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40


You can't just put code anywhere. It has to be in a constructor, initializer, or method.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Frank Harris
Greenhorn

Joined: Apr 07, 2010
Posts: 5
...oh jeez. I got it, thanks. I've been coding in java for almost a year now, and I am pretty damn embarrassed by this rookie mistake.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Homework Trouble: Not understood syntax error, Instance of a generic BST class