📜  字符串长度 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:27.307000             🧑  作者: Mango

代码示例6
//Methods used to obtain information about an object are known as accessor methods. One accessor method that you can use with strings is the length() method, which returns the number of characters contained in the string object. 

Example
public class StringDemo {

   public static void main(String args[]) {
      String palindrome = "Dot saw I was Tod";
      int len = palindrome.length(); // Using the length method
      System.out.println( "String Length is : " + len );
   }
}