1 package com.vince; 2 3 import java.util.Arrays; 4 5 public class StringDemo2 { 6 7 public static void main(String[] args) { 8 9 String str = " fkwefwfa d6737383 "; 10 char c = str.charAt(1); 11 System.out.println(c); 12 13 System.out.println(str.toCharArray()); 14 char[] cs = {'a','b','c'}; 15 String s1 = new String(cs); 16 17 String s2 = new String(cs,0,1); 18 System.out.println(s2); 19 20 System.out.println(Arrays.toString(str.getBytes())); 21 22 System.out.println(str.replace('w', '*')); 23 System.out.println(str.replaceAll("\\d", "*")); 24 25 System.out.println(str.substring(0, 4)); 26 27 System.out.println(Arrays.toString(str.split("d"))); 28 29 System.out.println(str.contains("a")); 30 31 System.out.println(str.indexOf("f")); 32 System.out.println(str.lastIndexOf("f")); 33 System.out.println(str.isEmpty()); 34 35 System.out.println(str.length()); 36 37 System.out.println(str.trim()); 38 39 System.out.println(str.concat("*****")); 40 System.out.println(String.valueOf(10)); 41 } 42 43 }View Code