package com.baidu.demo;
/**
* @author baozi
* @version 1.0
* @since 1.8
*/
public class Demo01 {
String name;
/**
*
* @param name
* @return
* @throws Exception
*/
public String test(String name) throws Exception{
return name;
}
//cmd 当前文件夹
//命令行 javadoc -encoding UTF-8 -charset UTF-8 Demo01.java
}
package com.baidu.demo.scanner;
import java.util.Scanner;
public class Demo01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("使用next方式接收:");
//判断是否有输入,hasNext()输出的是boolean类型,next()返回值
if (scanner.hasNext()){
//使用next方法接收
String str = scanner.next();
System.out.println("使用next方式输出:"+ str);
}
//凡是属于IO流的的类不关闭会一直占用资源
scanner.close();
}
}
package com.baidu.demo.scanner;
import java.util.Scanner;
public class Demo02 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("使用nextLine方式接收:");
//判断是否有输入,hasNext()输出的是boolean类型,next()返回值
if (scanner.hasNext()){
//使用next方法接收
String str = scanner.nextLine();
System.out.println("使用nextLine方式输出:"+ str);
}
//凡是属于IO流的的类不关闭会一直占用资源
scanner.close();
}
}
标签:String,System,笔记,next,public,Scanner,JavaSE,Day,scanner From: https://www.cnblogs.com/ez4baozi/p/17071475.html