leetcode 刷题的时候用到的较多 特来总结一下
package com.javalist;
/**
* 在java中String类可以定义字符串变量和字符串数组,
* length()用于求String字符串对象的长度,
* 而length用于求String字符串数组的长度。
* length()是求String字符串对象中字符的个数,
* 而length是求字符串数组中有多少个字符串。
* */
public class leetcode28substing {
public static void main(String[] args) {
String s1="asdgd";
String s2[]={"a","b","c"};
int lens1=s1.length();
int lens2=s2.length;
System.out.println(lens1);
System.out.println(lens2);
}
}