public class StringTest {
public static void main(String[] args) {
String s = "JAVASE";
for (int x = 0; x < s.length(); x++) {
System.out.println(s.charAt(x));
}
int arr[] = { 3, 25, 6, 26 };
for (int x = 0; x < arr.length; x++) {
System.out.println(arr[x]);
}
}
}
这里字符串数组和int数组在遍历时,求其长度时,s.length( )是调用方法,为什么arr.length后面没有括号? |
|