printstream class method println() is calling using System
class and its static object out .how it is explain any one
in detail with example ?
Answer / chandan kumar
import java.io.*;
class Other
{
public static PrintStream wise;
static
{
try{
wise=new PrintStream(new FileOutputStream("abc.txt"));
}
catch(Exception e)
{
}
}
}
public class AB
{
public static void main(String arg[])
{
Other.wise.println("hi");
}
}
This will print hi on a file abc.txt
some thing like this is written in class System. A static
object out of PrintStream Class is defined in static block
and connected to a Stream Connected to Console.So everythin
that we write with in print()method comes out as output
Is This Answer Correct ? | 12 Yes | 2 No |
What is a lightweight component?
what is the reason behind non static method cannot be referenced from a static Context?
What is the disadvantage of java?
Which data type is class in java?
What is difference between hashset and hashmap in java?
What does @param args mean in java?
What Method and class used for Connection pooling ?
Explain java coding standards for constants?
I have 100 records in a table with two rows. I need to display 10 records per page like Google Search. I need only the Logic(Pagination) in Pure Java. No JSP and all..Thanks in Advance...
Differentiate between vector and array list.
Does java set allow duplicates?
Can we execute java program without main method?