Quote:
Originally Posted by Zaid
I use the code
Code:
import java.lang.System;
class Demo
{
public static void main(String args[])
{
out.println("Hello");
}
}
but it is not working.....so u said wrong....and plz don't try to confuse me(with all those PHP's and irrelevant ****) when u seriously don't know the answer... 
|
I beg your pardon? Perhaps you are looking at my signature.
You are obviously not reading what I said:
Quote:
|
But for shortcut (ie: lazy ) usage, you can use it against the system.out for example, so you can just type in out.println. Unlike C#/VB, you can't get to the println this way as the PrintStream is an instance object and not a class.
|
You *must* have an instance of Java's PrintStream in order to invoke the println. The System.out is a static instance of PrintStream.
PHP Code:
import static java.lang.System.out; // You cannot statically import System.
public class myclass
{
public static void main(String argv[])
{
out.println("Hello world");
}
}
Quote:
Originally Posted by Zaid
Didn't buy it.... 
|
Unlike Java, C# uses a static console and static WriteLine. You can import the System.Console directly and invoke the methods without referring to the class.