Input in java - usage of java.util.Scanner

Eight basic data types and string types
package TX;

import java.util.Scanner;

public class Input {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		//Seven basic data types
		int i = input.nextInt();
		byte b = input.nextByte();
		Double d = input.nextDouble();
		Float f = input.nextFloat();
		short s = input.nextShort();
		long l = input.nextLong();
		boolean bo = input.nextBoolean();
		
		// string type
		String string = input.nextLine();
		
		//The acquisition of the character type cannot be obtained directly, but is obtained through a string
		String chString = input.nextLine();
		char ch = chString.charAt(0);
	}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325522420&siteId=291194637