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 what is the main difference between ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is the main difference between ..." Watch "what is the main difference between ..." New topic
Author

what is the main difference between ...

krishna Gajarla
Greenhorn

Joined: Oct 02, 2005
Posts: 21
hi every body, can any one pl.tell

what is the main difference between

out.println() and

System.out.println()


Thanks and Regards,<br />krishna<br />------------------<br />Charles Darwin: <br />"It is not the strongest of the species that survives, <br />nor the most intelligent, <br />but the one most responsive to change"
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
out.println typically won't compile, without out being defined somewhere. Where did you see this?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
I dont believe you can use just out.println();.

have to have the System.out.println().

System.out = monitor.
System.in = from keyboard.

-Justin-


You down with OOP? Yeah you know me!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18842
    
  40

I think we are going to see a lot more "out.println()" in code -- especially after people start to get comfortable with abusing the static import feature of Java 5.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

In light of Henry's answer, the full answer is:

In JDK 1.4 and earlier, "out.println()" is a compile error, while "System.out.println()" works.

In JDK 1.5 and later, "out.println()" is a compile error unless the line

import static System.out;

(or equivalent) is included in the source file. If this line is included, then out.println() is identical to System.out.println().


[Jess in Action][AskingGoodQuestions]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ernest Friedman-Hill:
In light of Henry's answer, the full answer is:

In JDK 1.4 and earlier, "out.println()" is a compile error, while "System.out.println()" works.

In JDK 1.5 and later, "out.println()" is a compile error unless the line

import static System.out;

(or equivalent) is included in the source file. If this line is included, then out.println() is identical to System.out.println().


Ouch, yes. I think Henry used the word "abuse" very wisely...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the main difference between ...