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

正文內(nèi)容

java程序設(shè)計(jì)教學(xué)課件5-免費(fèi)閱讀

  

【正文】 public class TestStringTokenizer { // Main method public static void main(String[] args) { // Create a string and string tokenizer String s = I am learning Java. Show me how to use StringTokenizer.。 public class Example5_7 { public static void main(String args[]) { String s=I am ,she is my girlfriend。 ? } 87 例 ? // Print the string buffer ? (strBuf)。 i++) ? { ? (i + | )。 ? for (int j=1。 ? // Get start time ? long startTime = ()。 StringBuffer s2=new StringBuffer(Hello )。 // s1和 s2代表同一個(gè)對(duì)象 ().append(39。 } } 78 StringBuffer類常用方法 (續(xù) ) 5. public void setCharAt(int index, char ch) 將參數(shù) index指定位置上的字符 , 設(shè)置成參數(shù) ch 指定的字符 。 // 設(shè)置容量為 80 (\nstr= +str)。 75 StringBuffer類常用方法(續(xù) ) void ensureCapacity(int NewCapacity) 設(shè)定對(duì)象的緩沖區(qū)的大小,若參數(shù) 小于對(duì)象的容量,則新的設(shè)置將不起作用,也就是說(shuō)容量只能擴(kuò)大而不能縮小。 3. public StringBuffer(String str) 初始內(nèi)容和參數(shù) str的內(nèi)容相同 , 容量為參數(shù) str的長(zhǎng)度加上 16。緩沖區(qū)的大小稱為對(duì)象的容量。 ? } ? 69 例 :驗(yàn)證回文串 ? // Check if a string is a palindrome ? public static boolean isPalindrome(String s) ? { ? int low = 0。 , 39。 66 String類常用方法 (續(xù) ) 9. public String concat(String str) 將 str對(duì)象接到調(diào)用對(duì)象的后面 , 返回新串 。 String s3=s2。 for (int i=6。 ( s1==s2 is +(s1==s2))。 應(yīng)用舉例 , 注意 程序 52的輸出結(jié)果: public class TestString{ // 程序 52 public static void main(String args[ ]) { String s1=Java, s2=Java。 等價(jià)于: char data[ ] = {39。 String str=new String(a,1,2)。J39。a39。 (str1==str2)。 // Display results (() + + + () + = + ((r2)).toString())。 } // Divide a rational number from this rational public Rational divide(Rational secondRational) throws RuntimeException { if (() == 0) throw new RuntimeException(Denominator cannot be zero)。 long d = denominator*()。 long remainder = t1%t2。 } } 44 public class Rational { private long numerator = 0?!闭Z(yǔ)句 ,y 的值將是 98. } } 43 this 關(guān)鍵字 this 關(guān)鍵字可以出現(xiàn)在類的實(shí)例方法中,代表使用該方法的當(dāng)前對(duì)象。 } } 41 ? 、 變量的作用域 我們已經(jīng)知道類體分為兩部分,變量定義部分所定義的變量被稱為類的成員變量。 // Change the radius in circle1 (9)。 } public void setRadius(double newRadius) { radius = newRadius。 36 類成員與實(shí)例成員 3. 初始化類變量和實(shí)例變量 說(shuō)明: ? 類初始?jí)K不能在任何方法內(nèi)。 //引用類型 int i = f()。 ? 實(shí)例方法只能由實(shí)例對(duì)象來(lái)調(diào)用而類方法即可以由實(shí)例對(duì)象調(diào)用也可以由類名直接調(diào)用。s radius by 10% (()*)。 public Circle() {radius = 。 printAreas(myCircle, n)。 ? } ? Circle() ? { ? radius = 。 ? 定義類時(shí)如未定義構(gòu)造方法,運(yùn)行時(shí)系統(tǒng)會(huì)為該類自動(dòng)定義缺省的構(gòu)造方法。 ? ? // Find the area of this circle ? double findArea() ? { ? return radius*radius*。 ? 被回收的對(duì)象是: 不再被任何引用變量引用的對(duì)象 ? 引用變量自動(dòng)放棄 ? 人為地將引用變量置為 null 10 .3 垃圾回收 清除對(duì)象 ? 垃圾回收器 當(dāng)系統(tǒng)的內(nèi)存用盡或程序中調(diào)用 ()要求進(jìn)行垃圾收集時(shí),垃圾收集線程與系統(tǒng)同步運(yùn)行。對(duì)簡(jiǎn)單變量來(lái)說(shuō),對(duì)應(yīng)內(nèi)存所存儲(chǔ)的值是簡(jiǎn)單類型,對(duì)對(duì)象類型來(lái)說(shuō),它的值是一個(gè)引用,是對(duì)象的存儲(chǔ)地址 對(duì)象變量的賦值和你直覺(jué)期望的不同 。 例 Rectangle rect = new Rectangle()。 mycircle = new Circle()。將 b1賦值給 b2并沒(méi)有分配任何內(nèi)存或?qū)υ瓕?duì)象做任何部分的拷貝。 //清除對(duì)象使用的所有資源,包括由于繼 //承關(guān)系而獲得的資源 } 12 訪問(wèn)對(duì)象的數(shù)據(jù)和方法 使用對(duì)象包括: ? 從對(duì)象中獲得信息 ? 改變對(duì)象的狀態(tài) ? 使對(duì)象執(zhí)行某些操作 實(shí)現(xiàn)途徑 : ? 引用對(duì)象的變量 ? 調(diào)用對(duì)象的方法 13 訪問(wèn)對(duì)象的數(shù)據(jù)和方法 例 : ? public class TestCircle ? { ? // Main method ? public static void main(String[] args) ? { ? Circle myCircle = new Circle()。 } Circle() { radius=。 ? (The area of the circle of radius ? + + is + ())。方法體內(nèi)局部對(duì)象的任何變化都會(huì)影響作為參數(shù)傳遞的原對(duì)象。 times。 } } 28 可見(jiàn)性修飾符與訪問(wèn)器方法 public class TestCircleWithPrivateModifier { // Main method public static void main(String[] args) { // Create a Circle with radius Circle myCircle = new Circle()。 ? 不管有多少類的實(shí)例,類變量只有一份拷貝,即所有實(shí)例共享相同的類變量;而每個(gè)實(shí)例對(duì)象都有自己的實(shí)例變量。 //類變量 boolean full = false。 class Spoon { static int i。 } public Circle(double r) { radius = r。 (circle1 is : )。 (circle2 is : )。 void f(){ int x=3。 =c。 = denominator/gcd。 } 47 // Getter method for numerator public long getNumerator() { return numerator。 } 4
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1