public static void main(String[] args) { //length 、length()、size()的区别 //length属性 针对数组长度 String a[]={"zhangsan","lisi","wangwu","zhaoliu"}; System.out.println(a.length); //length()方法 针对字符串 String b="zhangsanlisiwangwuzhaoliu"; System.out.println(b.length()); //size()方法针对泛型集合 List<String> person=new ArrayList(); person.add("zhangsan"); System.out.println(person.size()); }运行结果:
4
25
1
时间: 2024-10-09 01:08:42