Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

recusion again.  RSS feed

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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);
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
k, thx a lot, think i can handle it from here

this site is the greatest
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!