1. public int length ()
String s = "helloworld" ;
int length = s. lenght ( ) ;
2. public String concat (String str)
String s1 = "helloworld" ;
String s2 = s1. concat ( ",everyone" ) ;
3. public char charAt (int index)
String s = "helloworld" ;
char a = s. charAt ( 0 ) ;
char b = s. charAt ( 1 )
4. public int indexOf (String str)
String s = "helloworld" ;
int a = s. indexOf ( "l" ) ;
int b = s. indexOf ( "hwm" ) ;
5. public String substring (int beginIndex)
String s = "helloworld" ;
String a = s. substring ( 0 ) ;
String b = s. substring ( 5 ) ;
6. public String substring (int beginIndex, int endIndex)
String s = "helloworld" ;
String a = s. substring ( 0 , s. length ( ) ) ;
String b = s. substring ( 3 , 8 ) ;
7. public char[] toCharArray ()
String s = "helloworld!" ;
char [ ] a = s. toCharArray ( ) ;
8. public byte[] getBytes ()
String s = "HelloWorld!" ;
byte [ ] bytes = s. getBytes ( ) ;
9. public String[] split(String regex)
String s = "aa|bb|cc" ;
String[ ] strArray = s. split ( "\\|" ) ; for ( int i = 0 ; i < strArray. length; i++ ) {
System. out. print ( strArray[ i] ) ;
}
10. boolean contains(CharSequence s)
String s = "djlfdjksdlka" ;
boolean str = s. contains ( "g" ) ;
11. public String replace (CharSequence target, CharSequence replacement)
String str = "itcast itheima" ;
String replace = str. replace ( "it" , "IT" ) ;
12. public String toLowerCase()
String s = "HelloWorld!" ;
String a = s. toLowerCase ( ) ;
13. public String toUpperCase()
String s = "HelloWorld!" ;
String a = s. toUpperCase ( ) ;
14. public String trim()
String s = " HelloWorld! " ;
String a = s. trim ( ) ;
15. public boolean endsWith(String suffix)
String s = "HelloWorld" ;
boolean a = s. endsWith ( "World" ) ;
16. public boolean isEmpty()
17. public boolean startsWith(String prefix)
String s = "HelloWorld" ;
boolean a = s. startsWith ( "start" ) ;
18. public boolean startsWith(String prefix, int toffset)
String s = "HelloWorld" ;
boolean a = s. startsWith ( "Wor" , 5 ) ;
19. public boolean equalsIgnoreCase(String anotherString)