Scanner接收字符

char num = input.next().charAt(0);


//截取指定位置的字符,下标从0开始
System.out.println("helloworld".charAt(0)); //h
System.out.println("helloworld".charAt(1)); //e
System.out.println("helloworld".charAt(9)); //d
System.out.println("helloworld".charAt(5)); //w


猜你喜欢

转载自www.cnblogs.com/MRCH/p/11643767.html
今日推荐