首页 > 代码库 > String

String

 1 package pro1; 2  3 public class Pro1 { 4  5     public static void main(String[] args) { 6         // TODO code application logic here 7         System.out.println("test"); 8         //ask for the word‘s length 9         String s="welcome to beijin";10         int len=s.length();11         System.out.println(len);12         //concat13         String str="peggy";14         System.out.println(s.concat(str));15         str=str+s;16         System.out.println(str);17               18       String s1="This" ;19       String s2="That";20       System.out.println("Result 1:"+s1.equals("this")+","+s1.equalsIgnoreCase("this"));21       System.out.println("Result 2:"+s2.compareTo("That")+s2.compareTo(s1)+s2.compareTo("that"));22        // if it return -32 states : "That"is smaller than "this"(T<t) only both they are same return 0;m                                                                                   23         24     }25 }