import java.io.*;
 class WriteFile
{

public static void main(String ss[])
{

    try
    {

        FileWriter fw=new FileWriter("output.txt");
        PrintWriter pw=new PrintWriter(fw);
        String s1="Hello World";
        String s2="I Am Learning Java";
        pw.println(s1);
        pw.println(s2);
        pw.flush();
        pw.close();
        fw.close();
    }
    catch(IOException e)
    {

        System.out.println(e);
    }
}
}

in upper code println() is called with object of PrintWriter and confusion is that println() is the method of PrintStream how it is possible to call a method of a class with object of another class please clarify it

PrintWriter and PrintStream both implement a println method. Read their API doc for details.

ps: Your last three posts are still not "Solved". What's the problem?

send me the link of API doc for details

commented: Too lazy to look up Java API doc -3

How about using Google with keywords - java doc api PrintWriter - instead of asking someone else to do it for you?

Since when did I become your servant? Get off your *** and look it up for yourself.

@moaz, you might want to learn to be polite to people. It often helps to get help from them...
You might also learn to think for yourself, it helps you not need to ask for help so often.

And of course you might learn to search for information yourself, helps a lot too.
You can download the API docs (or reference them online) from the same place you can download the JDK...

if i am asking some question from you then you have to help me but you are not help me as you like what can i say.

commented: we HAVE to help you? wel excuse me, your Highness. -3

if i am asking some question from you then you have to help me but you are not help me as you like what can i say.

Excuse me, who are you to me? Are you a person who can determine my life? The way you use English is extremely rude in English native speaking culture. Your question is rude, and your reply is even worse. Your reply indicates that people on this site must serve you when you ask a question. This is unacceptable. Everyone here is a volunteer and does not ask for anything back from others.

We do because we would not mind sharing our knowledge. If you want someone to answer your questions without you lifting a finger, hire the person and stop using public forums.

In spite of the tone of your responses, I'll give you some help anyway.

The answer is that there is no relationship between the PrintWriter.println(String) method and the PrintStream.println(String) method. Yes, they look the same. Yes, you could change from one class to the other, and the calls would all still work. But technically, in Java, there is no relationship between these two "println" methods. They just happen to look the same and to do essentially the same thing.

You could determine this by looking at these two JavaDoc pages:
http://docs.oracle.com/javase/7/docs/api/java/io/PrintWriter.html#println(java.lang.String)
and
http://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html#println(java.lang.String)

After noticing that the descriptions of the two methods are essentially the same, scroll up to the top of both pages and notice that they have no parent classes in common (except for java.lang.Object, which does not define this method).

So there is no real technical issue involed here. It's only a matter of convention and expectations.

JeffGrigg thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.