一. length
length用于获取数组的长度,比如:
public class Main { public static void main(String[] args) { int test[] = {1,2,3,4,5,6,7,8,9,10}; System.out.println(test.length); } } 输出: 10
二. length()
length() 用于获取字符串的长度,比如:
public class Main { public static void main(String[] args) { int test[] = {1,2,3,4,5,6,7,8,9,10}; System.out.println(test.length); String s = "12345678910"; System.out.println(s.length()); } } 输出: 10 11
请登录之后再进行评论