2019-04-26面向?qū)ο蟮氖褂?/h2>
object          java.lang包下   
Hash值表示的是對(duì)象在內(nèi)存中的物理位置。
同一個(gè)對(duì)象的hashcode一定相同
Hashcode相同的對(duì)象一定是同一個(gè)對(duì)象


Equals()比較兩個(gè)對(duì)象是否相同
toString是方法將一個(gè)對(duì)象轉(zhuǎn)換為字符串


String
String類代表字符串
字符串是常量,它的值創(chuàng)建之后就不可以再修改了。
String類常用構(gòu)造方法
String() 無(wú)參構(gòu)造方法
String(String str) 有一個(gè)字符串參數(shù)的構(gòu)造方法
String(char[]ch) 有一個(gè)char類型數(shù)組參數(shù)的構(gòu)造方法
String(byte[] b) 有一個(gè)byte數(shù)組參數(shù)的構(gòu)造方法


int length() 求字符串值的字符個(gè)數(shù)
            boolean equals(Object o) 比較兩個(gè)字符串是否相同
 String replace(char old,char n) 字符串替換
        char charAt(int index) 返回指定字符串指定位置的字符
        boolean endsWith(String s) 比較字符串是否以指定的參數(shù)結(jié)尾
String valueOf(int i)將基本數(shù)據(jù)類型轉(zhuǎn)換為字符串
 boolean isEmpty() 判別一個(gè)字符串值的長(zhǎng)度是不是為0
        int indexOf(int ch) 用來(lái)檢查給定的一個(gè)字符在當(dāng)前字符串中第一次出現(xiàn)的下標(biāo)位置        
String substring(int begin)從指定索引位置截取字符串
StringBuilder delete(int start,int end):用于刪除給定字符串中的部分內(nèi)容。



==既可以比較基本數(shù)據(jù)類型,也可以比較引用數(shù)據(jù)類
比較基本數(shù)據(jù)類型的時(shí)候比較的是值
比較引用數(shù)據(jù)類型的時(shí)候比較的是地址
比較字符串的值是否相同equals

Math:
Scanner sc=new Scanner(system.in)
Double d=sc.nextDouble();
System.out.println(d);

//日期是從1900年開(kāi)始的
Date date=new Date();
//打印當(dāng)前時(shí)間
System.out.println(date);

//求絕對(duì)值
Int i=Math.abs(-1);
System.out.println(i);

//求兩個(gè)數(shù)的和
Int i2=Math.addExact(29,29);
System.out.println(i2);

//兩個(gè)數(shù)的最大值
Int i3=Math.max(28,29);
System.out.println(i3);


//求數(shù)的幾次方
double d=Math.pow(2,3);//2的3次方
System.out.println(d);

//返回一個(gè)0-1之間的隨機(jī)數(shù)
Double d=Math.random();
System.out.println(d);

int i=(int)(d*個(gè)數(shù))+基數(shù)  //求幾到幾的隨機(jī)數(shù)

//字符個(gè)數(shù)
String str="abcaa2ewr";
int i=str.length(); 
//替換一個(gè)字符
String str2=str.replace('a', 'b');
//替換多個(gè)字符
String str2=    str.replaceAll("a2e", "-");
//返回指定字符串指定位置的字符
        /*char c=str.charAt(50);
//比較字符串是否以指定的參數(shù)結(jié)尾
        /*boolean b=str.endsWith("ew2r");
/*int a=1;
        //將基本數(shù)據(jù)類型轉(zhuǎn)換為字符串
        String s=str.valueOf(true);
        System.out.println(s);  
        
        char [] c={'a','b','c','d','e','f'};
        String sc=str.valueOf(c, 3, 1);
        System.out.println(sc);*/
        //用來(lái)檢查給定的一個(gè)字符在當(dāng)前字符串中第一次出現(xiàn)的下標(biāo)位置 
    /*  String str="20-50-3-3-3";
        int i=str.indexOf('f');
            int i2= str.lastIndexOf('f');
        System.out.println(i2);
        //截取字符串
        String str2=str.substring(3,5); //包括前面的但是不包含后面的
        System.out.println(str2);
        //切割字符串
        String [] sr=str.split("-");
        for(int i=0;i<sr.length;i++){
            System.out.println(sr[i]);
        }*/


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容