返回字符串的长度

  public class ZongHe {
    public static void main(String[] args) {

        //调用function;

          function();

  }

   //int length();返回的是字符串长度
        public static void function(){
            String Str="skeji";  //定义字符串
            int  l=Str.length();  //计算字符串的长度赋值
            System.out.println(l);  //打印
    }
    
}

猜你喜欢

转载自www.cnblogs.com/hph1728390/p/10555350.html