package Number;
import java.util.Date;
public class First {
static String s1 = "Hello";
public static void main(String [] args) {
String str1="hello";
String str2=new String("world");
String str=str1+" "+str2;
System.out.println(str);
int booktime=4;
float practice=2.5f;
System.out.println("我每天花费"+booktime+"小时看书,"+practice+"小时听歌;");
int size=str1.length();
System.out.println(size);
int a=str1.indexOf("l");
int b=str1.lastIndexOf("l");
System.out.println(a+" "+b);
char c=str2.charAt(2);
System.out.println(c);
String str3=str2.substring(3);
System.out.println(str3);
str="123 222 2";
System.out.println(str);
System.out.println("原来的长度:"+str.length());
System.out.println("去除空格的长度:"+str.trim().length());
str=" 123 222 2 ";
System.out.println(str);
System.out.println("原来的长度:"+str.length());
System.out.println("去除空格的长度:"+str.trim().length());
String newstr=str.replace("2","a");
System.out.println(newstr);
String n1="221351";
String n2="3261351";
boolean b1=n1.startsWith("22");
boolean b2=n2.endsWith("352");
System.out.println(b1);
System.out.println(b2);
str1="ABC";
str2="abc";
b1=str1.equals(str2);
b2=str1.equalsIgnoreCase(str2);
System.out.println(b1+" "+b2);
str1="a";
str2="b";
str3="c";
str="b";
System.out.println(str.compareTo(str1)+" "+str.compareTo(str2)+" "+str.compareTo(str3));
System.out.println(str1.toUpperCase()+str2.toLowerCase());
str="192.168.0.1";
String[] first=str.split("\\.");
String[] secend=str.split("\\.",2);
System.out.println(str);
for(String k:first) {
System.out.print("["+k+"]");
}
System.out.println();
for(String l:secend) {
System.out.print("["+l+"]");
}
System.out.println();
Date date = new Date();
String year=String.format("%tY", date);
String month=String.format("%tB",date);
String day=String.format("%td", date);
System.out.println(year+"/"+month+"/"+day);
String regex="\\w+@+\\w+(\\.\\w{2,3})*\\.\\w{2,3}";
str1="aaa@";
str2="sssss";
str3="11@11fd.dfg.com";
if(str1.matches(regex)) {
System.out.println(str1+"合法Email");
}
if(str2.matches(regex)) {
System.out.println(str2+"合法Email");
}
if(str3.matches(regex)) {
System.out.println(str3+"合法Email");
}
}
}