首页 > 学院 > 开发设计 > 正文

JAVA用户数据输入

2019-11-15 00:16:27
字体:
来源:转载
供稿:网友
java用户数据输入 Posted on 2015-05-23 00:58 杨波php 阅读(...) 评论(...) 编辑 收藏

数据输入

首先需要导入扫描仪

然后声明扫描仪

输出输入提示

接收用户数据的数据

输出用户数据的数据

实例:

import java.util.Scanner;    //导入扫描仪public class Test{    public static void main(String[] args){        Scanner in    =    new Scanner(System.in);    //声明扫描仪,赋值扫描仪给in                System.out.PRintln("请输入你的姓名:");    //输出输入提示        String name    =    in.next();                //接收用户输入的姓名        /*接收用户输入时        in.next()是接收字符串类型        in.nextInt()是接收整型        in.nextDouble()是接收双精度型        */                System.out.println("请输入你的年龄");    //输出输入提示        int age    =    in.nextInt();                //接受用户输入的年龄                System.out.println("请输入你的性别");    //输出输入提示        String sex    =    in.next();                //接受用户输入的性别                //输出用户输入的所有信息        System.out.println("姓名"+name);        System.out.println("年龄"+age);        System.out.println("性别"+sex);    }}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表