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 恩师诗词祝福语简短大全