zoukankan      html  css  js  c++  java
  • Scanner 的用法

    public class ScannerDemo {
        public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            System.out.println("请输入您的金钱");
            // s.hasNext() 是否有next()值?
            if(s.hasNext()){
                String str = s.next();
                System.out.println(str);
            }
            // s.hasNextLine() nextLine()值?
            // 重点: 1、s.next()不支持空格、空白
            //  2、s.nextLine()支持空白、空格  === 》 常用
            if(s.hasNextLine()){
                String str = s.nextLine();
                System.out.println(str);
            }
    
            if(s.hasNextInt()){
                int num = s.nextInt();
                System.out.println(num);
            }else{
                System.out.println("您输入的不是整数");
            }
            // IO流一定要随手关闭 ★
            s.close();
        }
    }
    

      

    你的努力有资格到拼天赋的程度吗?
  • 相关阅读:
    调试
    自定义缓冲函数
    缓冲
    如何控制动画
    开发中遇到过的坑
    动画控制属性
    自定义动画
    CATransition(过渡)
    动画基础(显式动画)
    呈现图层
  • 原文地址:https://www.cnblogs.com/wchjdnh/p/14398129.html
Copyright © 2011-2022 走看看