输入输出

Posted yangyh26

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了输入输出相关的知识,希望对你有一定的参考价值。

1.输入

 

2.输出

2.1.println方法

  每次调用println都会在新的一行上显示输出。

1 public class Main {
2     public static void main(String[] args) {
3         System.out.println("123");
4         System.out.println("456");
5     }
6 }
1 123
2 456

2.2.print方法

  输出之后不换行。例如,System.out.print("Hello");打印“Hello”之后不换行,后面的输出“World”紧跟在字母“o”之后。

1 public class Main {
2     public static void main(String[] args) {
3         System.out.print("Hello");
4         System.out.print("World");
5     }
6 }
1 HelloWorld

以上是关于输入输出的主要内容,如果未能解决你的问题,请参考以下文章