package com;
public class GetCharAt {
public static void main(String[] args) {
String str ="明月几时有,把酒问青天";
System.out.println(str);
char c =str.charAt(2);
System.out.println("字符串中索引为2的字符是:"+c);
}
}
--------------------------------------------------------------------------------------------------
package com;
public class GetCharAt {
public static void main(String[] args) {
String str ="明月几时有,把酒问青天";
System.out.println(str);
char c =str.charAt(7);
System.out.println("字符串中索引为7的字符是:"+c);
char c2 =str.charAt(0);
System.out.println("字符串中索引为0的字符是:"+c2);
char c3 =str.charAt(str.length()-1);
System.out.println("字符串中最后一个字符是:"+c3);
}
}