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