Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

classes in multiple packages

  Asked By: Lewis    Date: Jun 27    Category: Java    Views: 911
  

I am importing two packages in my code that have a
class with the same name. How can I declare a
variable of this class type, and specify I want
java.x.ClassName rather than java.y.ClassName?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Willard Washington     Answered On: Jun 27

Assuming that I have written my own File class  and
placed them in com.vijay.File

To create a normal file Object the coode whould have
been
java.io.File normalFile = new java.io.File("some file
nane");

and to access the custome file class I will code  as
follows

com.vijay.File customeFile = new com.vijay.File("some
file name");

 
Didn't find what you were looking for? Find more on classes in multiple packages Or get search suggestion and latest updates.




Tagged: