freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

java編程異常處理ppt課件(編輯修改稿)

2024-11-12 23:41 本頁面
 

【文章內(nèi)容簡介】 ain(String args[]){ 3. String s1 = core java。 //字符串簡單創(chuàng)建方式 4. String s2 = new String(core java)。 //標準 new創(chuàng)建方式 5. String s3 = 。 //也是一個字符串 ,只是字符串沒有內(nèi)容 . 6. String s4 = null。 //null代表沒有對象 7. (s1+*+s2+*+S3+*+s4)。 8. } 9. } b. 常用構造器 public String(byte[] bytes) public String(byte[] bytes,int offset,int length) public String(byte[] bytes,Stirng charsetName) throws UnsupportedEncodingException public String(char[] value) public String(char[] value,int offset,int count) public String(String original) public String(StringBuffer buffer) 1. public class TestStringConstructor{ 2. public static void main(String args[]){ 3. String s1 = java核心技術大全 。 4. String s2 = new String((),iso8859_1)。 5. (將 s1轉換為 iso8895_1編碼格式,結果為 :+s2)。 6. String s3 = new String((iso8859_1),gb2312)。 7. (將 s1再轉換為 gb2312編碼格式,結果為 :+s3)。 8. } 9. } c. 重要方法 : public char charAt(int index) public byte[] getBytes() public byte[] getBytes(String charsetName) throws UnsupportedEncodingException public boolean equals(Object anObject) public boolean equalsIgnoreCase(String anotherString) public boolean endsWith(String suffix) public int indexOf(int ch) public int indexOf(String str) public String substring(int beginIndex) public String substring(int beginIndex,int endIndex) public String concat(String str) public String replace(char oldChar,char newChar) public String replace(CharSequence target,CharSequence replacement) public String[] split(String regex) public String trim() public String toString() public char[] toCharArray() public static String valueOf(參數(shù)列表 ) 1. public class TString 2. { 3. public static void main(String[] args) throws Exception 4. { 5. String ss = java core_java。 6. char c = (3)。 7. (c)。 8. String re = (.java)。 9. (re)。//java 10. boolean bo = (.java)。 11. (bo)。 12. byte[] by = ()。 13. int i = (39。a39。)。 14. (i)。 15. int ii = (core)。 16. (ii)。 17. String sr = (39。a39。,39。b39。)。 18. (sr)。 19. String[] sa = (\\.)。 20. for(String obj:sa){ 21. (obj)。 22. } 23. String sub = (6, 10)。 24. (sub)。 25. String st = ()。 26. (st)。 27. String sd = ()。 28. (sd)。 29. } 30. } d. String對象的內(nèi)存機制 1. public class TestString 2. { 3. 4. public static void main(String[] args) 5. { 6. String s1 =Java編程 。//象 7. String s2 =Java編程 。 8. String s3 =new String(Java編程 )。//的構造器創(chuàng)建對象 9. if(s1==s2){ 10. (字符串 s1和 s2通過等于測試,結果返回 True)。 11. } 12. else{ 13. (字符串 s1和 s2通過等于測試,結果返回 False)。 14. } 15. if(s1==s3){ 16. (字符串 s1和 s3通過等于測試,結果返回 True)。 17. } 18. else{ 19. (字符串 s1和 s3通過等于測試,結果返回 False)。 20. } 21. if((s3)){ 22. (字符串 s1和 s2內(nèi)容相同,結果返回 True)。 23. } 24. else{ 25. (字符串 s1和 s2內(nèi)容不相同,結果返回 False)。 26. } 27. } 28. } 用簡單方式創(chuàng)建的字符串放在池中,如果再次用簡單方式創(chuàng)建任何已在池中存在的字符串,將不會再在池中分配空間,而是讓新的對象的引用指向池中已存在的字符串。 new出來的字符串先在堆中開辟一塊空間,然后再到池中去找看有沒有相同的一個字符串,如果沒有相同的字符串,也會在池中創(chuàng)建一個同樣的字符串,并會把兩者聯(lián)系起來。若存也會把兩者聯(lián)系起來。 String特殊機制讓我們比較字符串時,不管字符串有多長,其比較速度都是一樣的,國為在比較兩個字符串內(nèi)容是否相時,不必真去考察內(nèi)容,只需比較兩個字符串聯(lián)系的常量池中對象是否為同一個即可 . String類對象永不可變 ,在一些需要大量連接字符串的代碼中,其性能將大幅下降 . B. StringBuffer類 為了彌補 String在連接操作中的缺點, java提供了一個 StringBuffer類 StringBuffer對象的創(chuàng)建語法只有一種 .使用 new操作符 StringBuffer類的構造器 : public StringBuffer() public StringBuffer(String str) StringBuffer類的重要方法 : public StringBuffer append(String str) public StringBuffer insert(int offset,String str) public StringBuffer delete(int start,int end) public StringBuffer reverse() public String toString() StringBuffer類也有 equals方法,但是其功能相當于將兩個引用進行“ ==”比較 Math類提供了很多數(shù)學計算的方法,這些方法都是靜態(tài)的方法 . 常用方法 : public static double sin(double a) public static double cos(double a) public static double pow(double a,double b) public static double sqrt(double a) public staic int abs(int a) public static double ceil(double a) public static double floor(double a) public static long max(long a,long b) public static int min(int a) Object類是所有類的父類, java中的類都是直接或間接繼承自 Object類 1. public class MyInteger 2. { 3. private final int value。 4. 5. public MyInteger(int value){ 6. = value。 7. } 8. 9. public int getValue(){ 10. return 。 11. } 12. 13. public boolean equals(Object obj){ 14. if(obj==null) 15. return false。 16. if(obj instanceof MyInteger){ 17. return value==((MyInteger)obj).getValue()。 18. } 19. else 20. return false。 21. } 22. 23. public int hashCode(){ 24. return ().hashCode()+37。 25. } 26. 27. public String toString(){ 28. return +。 29. } 30. 31. public static void main(String[] args) 32. { 33. MyInteger m1 = new MyInteger(10)。 34. MyInteger m2 = new MyInteger(10)。 35. (m1)。 36. ((m2))。 37. } 38. } 重要字段 : public static final InputStream in public static final PrintStream out 重要方法 : arraycopy(Objec
點擊復制文檔內(nèi)容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1