Java程序以获取位于字符串的指定索引处的字符
使用charAt()Java中的方法来获取位于指定索引处的字符。
假设以下是我们的字符串。
String str = "Laptop...";
在3查找字符第三位置。
str.charAt(2);
以下是最后一个示例。
示例
public class Demo {
public static void main(String[] args) {
String str = "Laptop...";
System.out.println("String: "+str);
System.out.println("Character at position 3 = " +str.charAt(2));
}
}输出结果
String: Laptop... Character at position 3 = p
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短