wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes recusion again. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "recusion again." Watch "recusion again." New topic
Author

recusion again.

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok, i'm having a problem with a method...

class one..



Now here is my main....



ok, so the ReverseIt() method is giving me some trouble, and i dont know why...

please help, thank you


You down with OOP? Yeah you know me!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Monk Fox:
...


ok, so the ReverseIt() method is giving me some trouble, and i dont know why...

ReverseIt is an instance method (not static), so you need to create an instance of Inovate in order to call the method...

Inovate in = new Inovate();
in.ReverseIt(a);


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok so if i wanted to call the method like this....

ReverseIt(a);


i would have to do this?

public static class Inovate
{
public static String ReverseIt()
{}
}

like that huh?

but i can't believe i missed that lol, thx for the help
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Monk Fox:
ok so if i wanted to call the method like this....

ReverseIt(a);


i would have to do this?

public static class Inovate
{
public static String ReverseIt()
{}
}

like that huh?

but i can't believe i missed that lol, thx for the help

Well, a top-level class can't be static, but a method defined in that class can be static. In that case, you could call the method using the class name...

Inovate.ReverseIt();

If ReverseIt were defined within scope (e.g., in the same class as main), then you could call the method without qualification -- that is, without the class name. But it looks like you have two separate classes here, so the compiler won't know what "ReverseIt" means unless you specify the class with "Inovate.ReverseIt".
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
k, thx a lot, think i can handle it from here

this site is the greatest
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: recusion again.