Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

println

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the best way to explain using System.out.println vs out.println??
 
Greenhorn
Posts: 13
Android Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not totally sure what your question is, so I will explain the usage of System.out.println() and out.print() (where out is a local variable set to System.out):



System.out is a public static member of the java.lang.System class that contains (among many other things) a static method called println(). To use out.println(), we have to declare a variable of type PrintStream called "out" to hold a reference to System.out.

Why you would want to do this escapes me, but there it is.

--jsp

Output:

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

As Steven has already said it's not clear what your question actually means. If Steven hasn't already provided you with the answer please provide more detail so we can hep you.
 
Marshal
Posts: 74371
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chances are, you have seen a class with a static import. That is almost as if the imported member of the class were a private static member of your class. So you can use out by importing it from the System classRead a little more about static imports here.

The out field is a static member of the System class, but all its methods that I have seen are instance methods (not static), so you can't use static import twice and write println.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic