aspose file tools*
The moose likes Beginning Java and the fly likes too much simple question: call public method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "too much simple question: call public method" Watch "too much simple question: call public method" New topic
Author

too much simple question: call public method

abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635


Error:

can not find symbol

Problem is about this.displayGreeting(); and z.displayGreeting();
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4490
    
    8

Both those lines try to call the displayGreeting() method on an object of class s (by the way, don't use lower case letters for class names - especially single letters! - as it makes it harder to read). But that class doesn't gave that method.
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
How can I define displayGreeting(); method so it can be acessed from any where?( other than static)
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4490
    
    8

Your displayGreeting() method is accessible from anywhere. But it belongs to the Outer class. Which means you can only call it on an instance of an Outer object. You can't then just call it on any old object.

In object-oriented programming you'll often see interactions between objects described as "sending messages". One object sends a message to another object, which replies. The messages you can send to an object correspond to the methods that object has.

In this case, you're trying to send a message to an object that doesn't understand it. You can tell a dog to bark, you can't tell a daffodil to!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: too much simple question: call public method