aspose file tools*
The moose likes Beginning Java and the fly likes explain the statement   import java.io.File.*; 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 "explain the statement   import java.io.File.*;" Watch "explain the statement   import java.io.File.*;" New topic
Author

explain the statement import java.io.File.*;

lakshmana dhanimireddi
Greenhorn

Joined: Jul 05, 2011
Posts: 18

What is the meaning of


import java.io.File.*;

class Sample
{
}



the above file class is successfully compiled. But I can't understand the meaning of import statement.

Can you explain?

Thanks,
Lakshmana
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
It looks like a mistake to me. It means, if you can't find a class, go and look in the package called java.io.File. Obviously all classes were found, so the compiler didn't have to look in that package. I think it was supposed to have the keyword static in there somewhere.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19781
    
  20

Or it's trying to import all nested classes / interfaces. It doesn't really matter that there aren't any, the syntax is still legal.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
lakshmana dhanimireddi
Greenhorn

Joined: Jul 05, 2011
Posts: 18

Thanks to all.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: explain the statement import java.io.File.*;