Home  >  Article  >  Java  >  How to write input statement in java

How to write input statement in java

王林
王林Original
2020-04-30 16:42:0919247browse

How to write input statement in java

The user input statement in java is written as:

1. [Scanner sc = new Scanner(System.in); 】;

2 , [String input = sc.next();].

(Recommended video tutorial: java video)

The specific code is as follows:

import java.util.Scanner;
 
public class Number {
 
/**
* @param args
* author:sun
* time:2011-05-25 12:10
*/
public static void main(String[] args) {
   // TODO Auto-generated method stub
   System.out.println("请输入内容:");
   Scanner sc = new Scanner(System.in); 
   String input = sc.next();
   System.out.println("你输入的内容为:"+input);
}
}

Recommended tutorial: java entry program

The above is the detailed content of How to write input statement in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is java webNext article:what is java web