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 are different type of exceptions in java?
Why main() method is public, static and void in java ?
How can be define MARKER interfce in java
What the difference is between execute, execute Query, execute Update?
What is java virtual machine? Explain
How to sort a vector elements that contains the user define class object? (Note: If Suppose consider, A Student class contain two data members. They are String studentName and int rollNo. I am creating Four objects for this class, each object contains students details like name and roll no. Now i am storing that objects in vector and if i retiving the elements from the vector means then it should be display in sorting order)
3 Answers ProdEx Technologies,
Name component subclasses that support painting in java programming?
What is e java?
What are keywords give examples?
Is intellij better than eclipse?
Can you call a method on a null object?
What is difference between stringbuffer and string?