区别:
- System.out.println() 输出信息后追加一个换行
- System.out.print()输出之后不追加换行
实例:
(1)System.out.println()
package tes; public class OutputTest { public static void main(String[] args) { String[] st = {"a","b","c","d"}; for(int i = 0; i < st.length; i++ ){ System.out.println(st[i]+""); } } }
打印效果:
a b c d
(1)System.out.print()
package tes; public class OutputTest { public static void main(String[] args) { String[] st = {"a","b","c","d"}; for(int i = 0; i < st.length; i++ ){ System.out.print(st[i]+""); } } }
打印效果:
abcd