Home> Java> JavaBase> body text

How to write input statement in java

王林
Release: 2020-04-30 16:42:09
Original
19268 people have browsed it

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); } }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!