The difference between print, println, printf's
-
print output does not wrap, only one parameter, the cursor is positioned at the last character of the line
int a=10;
System.out.print("哈哈");
System.out.print(a);
-
println with similar print output but wrap, only one parameter, the cursor is positioned at the beginning of the next line
int a=10;
int b=2;
System.out.println("哈哈");
System.out.println(a);
-
printf output does not wrap, the cursor is positioned at the last character string of the line, for printing formatted
Can not directly output the basic data types, you specify a formatting rule to use it.
int a=10;
int b=2;
System.out.printf("哈哈");
System.out.printf("haha,%d,%d",a,b);