charAt和String的用法

package charpter2;

import java.util.Scanner;

public class Test {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
System.out.println("请输入您想输入的内容:");
/*int num = sc.nextInt();
System.out.println(num);
String name = sc.next();
System.out.println(name);
boolean answer = sc.nextBoolean();
System.out.println(answer);*/

String str = sc.next();
System.out.println("abcd");
// charAt(参数跟数组差不多都是从0起123等等,第几个就是从0起到该字母为止)
char c = str.charAt(0);
System.out.println(c);
char c1 = str.charAt(3);
System.out.println(c1);

}
}

上一篇:九天学会Java,第四天,循环结构


下一篇:bzoj 2186 [Sdoi2008]沙拉公主的困惑 欧拉函数