aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static Imports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static Imports" Watch "Static Imports" New topic
Author

Static Imports

Robert Darling
Ranch Hand

Joined: Jun 21, 2008
Posts: 100

Hi,

Just a quick question regarding static imports.
When we say


println is a function. So is out a class ??? So to import static function println we would say


Is the rule for Static Imports that the right most entry must be a static function. ???

Kind Regards

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18845
    
  40

Sajjad Dar wrote:
println is a function. So is out a class ??? So to import static function println we would say


"out" is a static variable of the System class.

Sajjad Dar wrote:
Is the rule for Static Imports that the right most entry must be a static function. ???


I believe you can import anything that is declared static -- static inner (nested) classes, static methods, or static variables.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Henry Wong wrote:
Sajjad Dar wrote:
println is a function. So is out a class ??? So to import static function println we would say


"out" is a static variable of the System class.


Henry


is "out" is a variable or a inner class?


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Robert Darling
Ranch Hand

Joined: Jun 21, 2008
Posts: 100

if out is static variable how can you call the println function on it?
How do we know what is a package and what is a class ?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You'll probably understand by looking at the API of the java.lang.System class.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static Imports