File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes is it valid import? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "is it valid import?" Watch "is it valid import?" New topic
Author

is it valid import?

Raja seemakurthi
Greenhorn

Joined: Jun 28, 2007
Posts: 17


some where i have seen that the above import statement is not a valid statement, we should get a compile time error.
but it is compiling perfectly.

am i wrong?
please provide your comments.

Thanks,
Raja


Thanks,
Raja
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

From Java 5, you can import static variables from a class that way. It means "Import all static variables from the Date class". It would have been an error in Java 1.4.


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Aaahhh, there's no "static" keyword in the import. Forget about the previous post.
It allows you to import inner classes. Check this.
Raja seemakurthi
Greenhorn

Joined: Jun 28, 2007
Posts: 17
Christophe Verré wrote:From Java 5, you can import static variables from a class that way. It means "Import all static variables from the Date class". It would have been an error in Java 1.4.


that's good.
i know that import static java.package1.class1.*; is a valid statement, but what about if a class is not having any static fields then import java.package1.class1.*;
works fine? is it won't give any compile time errors? please clarify
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Did you read my second post ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is it valid import?
 
Similar Threads
Do you use a bean for creating database connection?
Why can't use javac to compile servlet?
Accessing instance variable
SubClass Constructor Question
How do I solve the problem:Syntax error on tokens, delete these tokens?