GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes calling method from another package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "calling method from another package" Watch "calling method from another package" New topic
Author

calling method from another package

dale con
Ranch Hand

Joined: Apr 15, 2005
Posts: 93
Hello

I have a package com.mypackage which has some methods

I have another package com.anotherapckage and i want to use a mehod in com.mypackage. How do i do this?

I've imported the package import com.mypackage then MyClass myclass = new MyClass();, but non of the methods are exposed

Many thanks
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I need some more information in order to help you. What compiler errors do you get? Also, please post the code for MyClass and the class that is trying to use methods from it.

Layne


Java API Documentation
The Java Tutorial
dale con
Ranch Hand

Joined: Apr 15, 2005
Posts: 93
It's OK sorted it. Needed to make the method static

Cheers
 
jQuery in Action, 2nd edition
 
subject: calling method from another package