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);

}
}

posted @ 2018-08-03 18:06  Monica_维维  阅读(406)  评论(0编辑  收藏  举报