zoukankan      html  css  js  c++  java
  • scnner02 (nextLine)

    package com.lyc;
    import java.util.Scanner;

    public class Demo02 {
    public static void main(String[] args) {
    //创建一个扫描对象,用于接收键盘数据
    Scanner scanner = new Scanner(System.in);
    System.out.println("使用nextLine方式接收:");
    //判断用户有没有输入字符串
    if (scanner.hasNext()){
    //使用nextLine方式接收
    String str = scanner.nextLine();
    System.out.println("输出内容为"+str);
    }
    //凡是属于IO流的类如果不关闭会一直占用资源,养成好习惯用完就关闭
    scanner.close();


    }
    }
  • 相关阅读:
    web--ajax--json
    4.26
    4.25
    4.23
    4.22
    4.20
    4.19
    4.18
    4月问题总结章
    4.17
  • 原文地址:https://www.cnblogs.com/liuyunche/p/14238173.html
Copyright © 2011-2022 走看看