package 常用类;
import java.awt.color.ICC_ColorSpace;
import java.security.AlgorithmConstraints;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test1 {
public static void main(String []args)
{
String str1 = "abcd";
String str2 = "abcd";
System.out.println(str1 == str2);
String stra = new String("abcd");
String strb = new String("abcd");
System.out.println(stra == strb);
System.out.println(stra);
System.out.println(strb);
System.out.println(stra.equals(strb));
Person p1 = new Person("Zhang");
Person p2 = new Person("Lee");
Person p3 = new Person("Lee");
System.out.println(p1.equals(p2));
System.out.println(str1.indexOf('b'));
System.out.println(str1.lastIndexOf(0));
String[] aa = str1.split("-");//
str1.charAt(1);//字符串截取 字符
char[] chartest = {'h','e','l','l','o'};
String charString = new String(chartest);
System.out.println(str1.trim().length());//trim 空格
//+
String a = "hello";
String b = "world";
String c = a+b ;
StringBuffer sf = new StringBuffer("test");
sf.append("aaaaaaa");
sf.append("BBBBBBB");
sf.insert(10, "hello");//testaaaaaahelloaBBBBBBB
System.out.println(sf);
System.out.println(sf.toString());
//练习
System.out.println("----------START--------");
String test = "Hello World";
System.out.println(test.length());//长度
System.out.println(test.indexOf('o'));//输出第一个o的索引
System.out.println(test.lastIndexOf('o'));//输出后一个o的索引
test = test.replaceAll("l", "m");
System.out.println(test);
String[] ary = test.split(" ",2);//分割
System.out.println(ary[0].equals(ary[1]));//比较
System.out.println("----------END------------");
// 包装类:int(Integer) double char(Character)
//float long short byte boolean
int i = 6;
Integer ia = new Integer(i);
System.out.println(ia.intValue());//包装类转化成基本数据类型
System.out.println(i);
Integer inter = new Integer(4);
inter.valueOf("1234");
//Date类
Date date = new Date();//获得当前日期和时间
System.out.println(date);
//格式化日期
Date date1 = new Date(36000000);
System.out.println(date1);
System.out.println(date.getTime()==date1.getTime());
if(date.getTime() > date1.getTime())
{
System.out.println("date在之后");
}
else if (date.getTime() == date1.getTime())
{
System.out.println("相等");
}
else {
System.out.println("date1在之后");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
String dates = sdf.format(date);
String date1s = sdf.format(date1);
System.out.println(dates);
System.out.println(date1s);
System.out.println(dates.equals(date1s));//返回True,false
System.out.println(dates.compareTo(date1s));//返回
if(dates.equals(date1s))
{
System.out.println("Equal");
}
else {
System.out.println("Not Equal");
}
String[] strs = dates.split("-");
String[] str1s = date1s.split("-");
//. if(strs[0].equals(strs[1]))
//Math
System.out.println(Math.log(2.77));
System.out.println(Math.abs(-2.5));
System.out.println((int)(Math.random()*100));
}