Meysam
Meysam

Reputation: 185

Example of using Java Packages

I'm playing around with Java.

Consider I am writing a class named:
AA.java under package name SoUnique.
And my friend comes with a package name AnotherUniqueName which includes a file name AA.java.

How can I use his methods in his package? Does my example make sense at all? Should I import anything? How does packaging help to avoid conflicting names?

Upvotes: 1

Views: 241

Answers (2)

SMA
SMA

Reputation: 37073

use fully qualified package name (assuming it has myfun method) like:

AnotherUniqueName.AA.myfun();

Upvotes: 9

mahesh
mahesh

Reputation: 1331

If you want to call a non static method you can create object and call your method.

AnotherUniqueName.AA obj=new AnotherUniqueName.AA();
obj.yourMethod();

Upvotes: 2

Related Questions