Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static Imports

 
Robert Darling
Ranch Hand
Posts: 100
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Robert Darling
Ranch Hand
Posts: 100
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll probably understand by looking at the API of the java.lang.System class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic