Java String class learning fourth day

/ * 
* Get the string length of the String.length () 
* string is case-sensitive comparison String.equals (String str) returns true or false 
* case-insensitive string comparison String.equalsIgnoreCase (String str); return true or false 
String.charAt * returns the character at the specified index (int index) 
* find a location String.indexOf parameter string is first found in the original string (string str) return to find the location of the index, not found returns -1 
* string splicing String.concat (string str) returns a new string object after splicing 
* string during the program run, its value can not be changed. also called string constants. 
* string interception String.substring (int index) returned from subscript index start to end of the string 
* String.substring (int a, int b ) returns a string from the subscript b-1 start to the end of the subscript 
* * / 

Import java.sql.SQLOutput; 

public  class StringDemo {
     public  static  void main (String [] args) { 
        String STR  = "Your the Begin challeging your own Assumptions Assumptions are your Windows ON OFF The World Scrub Them A Every Once in the while, or in The Light Will Not Come.." ;
         // Get string length 
        System.out.println (str. length ());
         // distinction is the case, two strings are equal 
        System.out.println (str.equals ( "Hello" ));
         // not case-sensitive comparison whether the two strings are equal 
        System.out. the println (str.equalsIgnoreCase ( "Hello" ));
         // get the first character of a value 
        System.out.println (str.charAt (0 ));
         // Get the character subscript e 
        System.out.println (str .indexOf ( "E" ));
         // find the specified character index, and returns the character string in the index, not found -1
        System.out.println (str.indexOf ( 'C',. 3 ));
         // taken from the start to the end of the specified index string 
        System.out.println (str.substring (10 ));
         // taken from the specified start index string to the end of the specified superscript -1 
        System.out.println (str.substring (10,15 )); 
    } 
}

 

Guess you like

Origin www.cnblogs.com/vxiao2/p/11488241.html