Is there a difference in using these two? When would you use one over the other?
System.out.println(result);
versus
PrintWriter out = new PrintWriter(System.out);
out.println(result);
out.flush();
Is there a difference in using these two? When would you use one over the other?
System.out.println(result);
versus
PrintWriter out = new PrintWriter(System.out);
out.println(result);
out.flush();
I recommend using PrintWriter if you have to print more than 10^3 lines in one go.

I got this by running these snippets 3 times each for n=10^1 to 10^7 and then taking mean of there execution time.
class Sprint{
public static void main(String[] args) {
int n=10000000;
for(int i=0;i<n;i++){
System.out.println(i);
}
}
}
import java.io.*;
class Pprint{
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
int n=10000000;
for(int i=0;i<n;i++){
out.println(i);
}
out.flush();
}
}