Can't call methods

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Steven

Can't call methods

Post by Steven »

I have two programs. One has all the junk and the other is the main one that tests it. I keep getting compiler errors that state that it 'cannot resolve symbol' when I try to make the call to the other method. Can anyone give me some begining tips with this? The code would way to long to put here but hopefully someone can make a shot in the dark and figure out my problem. Thanks.
Steven

Re: Can't call methods

Post by Steven »

class Monkey
{
public static String Ohh()
{
System.out.println("Uggg");
return ("bite me");
}

public static String Ahh()
{
System.out.println("It works!");
return ("hello");
}
}
class testAhh
{
public static void main(String [] args)
{
new Ahh();
new Ohh();
}
}
Ok, tell me why this works for 'Ahh' but I get a compiler error for 'Ohh'. These are in two seperate files.
Henrik S. Larsen

Re: Can't call methods

Post by Henrik S. Larsen »

Is the methods alone in 2 files or what?
I tried to put class Monkey with the 2 methods in one file
and the testAhh class in another.
I got compile errors on both methods.
However, a small change and voila! Works.

mvh / regards
Henrik

public class testAhh
{
public static void main(String [] args)
{
Monkey gorilla = new Monkey();
gorilla.Ahh();
gorilla.Ohh();
}
}
Post Reply