user975705
user975705

Reputation: 331

Problems accessing public method of another class

I currently use two classes, ircBot(extends pircbot) and ircRobotti(extends Robotti).

I'm trying to compile the class files on a shell but i'm getting an error:

./ircBot.java:26: cannot find symbol symbol : method lisaaJonoon(int) location: class Robotti annaRobo().lisaaJonoon(suunta);

lisaaJonoon() is defined in ircRobotti and it's public.

Any ideas what might cause the error?

Upvotes: 0

Views: 139

Answers (3)

Ehtsham ul Haq
Ehtsham ul Haq

Reputation: 41

A public method from one class will be accessible in other class if you make sure that

1: Both classes are in same package. If they are in different packages then you need to import the class whose method you are calling.

2: The class whose method is being called, should also be compiled.

3: Make sure, method signatures are same as in called method. (i.e. the number of arguments an d their type)

Upvotes: 1

blank
blank

Reputation: 18170

Just a guess but as you are compiling on a shell you're probably not setting the classpath correctly. How are you invoking javac?

Upvotes: 0

Prince John Wesley
Prince John Wesley

Reputation: 63688

lisaaJonoon(int) has a parameter of type int which is different from lisaaJonoon().

Upvotes: 1

Related Questions