抱歉,我的问题有点难以理解。所以在一个数组中,例如 String []arr = {"abs, "def", "ghi"}; 我想知道它如何打印出来 A e 我
这是我尝试编写但失败的代码。
public static void printCharsAt(String[] arr) {
System.out.println("how many inputs do you want in your array");
String array[] = {"hello", "Ap", "CS"};
System.out.println("What term of the array do you want, do you wan the first, 2nd, or third");
tnt char = kb.nextInt();
System.out.println(array[char]);
}
最佳答案
没有任何边界检查:
for (int i=0; i<arr.length; i++)
System.out.println(arr[i].charAt(i));
关于java - 如何在给定的字符串数组的字符串索引处打印出该字符串的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8411984/