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

正文內(nèi)容

java程序設(shè)計教學(xué)課件5(更新版)

2025-06-26 18:25上一頁面

下一頁面
  

【正文】 新的 string對象 。,39。,39。 (Java==Java)。 (() + + () + = + ((r2)).toString())。 long n = numerator*()。 return new Rational(n, d)。 while (remainder != 0) { t1 = t2。 private long denominator = 1。 例: class trangle{ double a,b,c。 局部變量 : 在方法體中定義的變量和方法的參數(shù)被稱為局部變量。 40 例 // Display circle1 and circle2 AFTER circle2 was created (\nAfter creating circle2 and modifying + circle139。 } public static int getNumOfObjects() { return numOfObjects。 ? 類初始塊只執(zhí)行一次 37 例 class Circle { private double radius。 //通過調(diào)用一個方法來提供初始值 } 34 類成員與實例成員 3. 初始化類變量和實例變量 實例變量:在構(gòu)造方法中進(jìn)行初始化。 32 類成員與實例成員 說明: ? 可用 static來定義全局變量和全局方法,這時由于類成員仍然封裝在類中,與 C、 C++相比,可以限制全局變量和全局方法的使用范圍而防止沖突。 (The area of the circle of radius + () + is + ())。} public Circle(double r) {radius = r。 // See and times (\n + Radius is + + n is + n)。 ? } ? double findArea() ? { ? return radius*radius*。 ? 沒有任何參數(shù) ? 沒有 body ? 不做任何事情 20 例 ? class TestCircleWithConstructors ? { ? public static void main(String[] args) ? { ? //Test Circle with radius ? Circle myCircle = new Circle()。 ? } ? } 15 訪問對象的數(shù)據(jù)和方法 使用一個對象之前必須先創(chuàng)建它 . 16 類體為該類的對象提供了在生存期內(nèi)需要的所有代碼。否則垃圾收集器在系統(tǒng)空閑時異步地執(zhí)行。 例如 , 你認(rèn)為下面的程序段是做什么呢 ? Box b1 = new Box()。 創(chuàng)建一個對象包括三部分: ? 聲明部分 ? 實例化部分 ? 初始化部分 5 .1 聲明和創(chuàng)建 對象 ? 聲明對象 聲明對象的名字和類型,用類名來說明對象的類型。 6 聲明和創(chuàng)建 對象 創(chuàng)建對象 操作符 new通過為新對象分配存儲空間來實例化類 格式: new 類的構(gòu)造方法 例 new Circle()。也就是,你可能認(rèn)為 b1和 b2引用的是不同的對象,但實際情況卻相反, b1和 b2將引用同樣的對象。 finalize( )方法在類 如: protected void finalize ( ) throws throwable{ …… // clean up code for this class super. finalize( )。 例如: Circle(double r) { radius=r。 ? ? //Test Circle with default radius ? Circle yourCircle = new Circle()。 傳遞對象意味著將對象的引用傳遞給形參。 ++。} public double findArea() { return radius*radius*。 [static] returnType classMethod ( [paramlist] ){ …… } 30 類成員與實例成員 1. 類變量與實例變量 二者區(qū)別: ? 運行時系統(tǒng)在首次遇到類變量時就為類變量存儲空間;而當(dāng)創(chuàng)建類的實例對象時才為實例變量分配存儲空間。 33 類成員與實例成員 3. 初始化類變量和實例變量 ( Instance and Class Members) ? 可以在類中聲明的時候初始化 class BedAndBreakfast { static final int MAX_CAPACITY = 10。 } // . . . 35 類成員與實例成員 3. 初始化類變量和實例變量 類變量:類初始塊中進(jìn)行初始化。 numOfObjects++。 // Display circle1 BEFORE circle2 is created (Before creating circle2)。 printCircle(circle1)。 class Tom{ int x=98,y。 =b。 = numerator/gcd。 } return t2。 return new Rational(n, d)。 } 50 // Override the toString() method public String toString() { if (denominator == 1) return numerator + 。 } } 52 字符串的分類 ? String和 StringBuffer兩個類; ? 在運行中值不會改變的字符串,用 String類存儲;值會改變的字符串用 StringBuffer類來存儲。 2. public String(char value[ ]) 將字符數(shù)組的內(nèi)容轉(zhuǎn)換為字符串 , 并賦予新建的對象 。a39。v39。 (str2)。, 39。 s1=ABC。 3. public int pareTo(String anotherString) 對字符串內(nèi)容按字典序進(jìn)行大小比較。 6. public boolean equalsIgnoreCase(String anotherString) 以忽略大小寫方式,比較兩個字符串對象的內(nèi)容是否相等。 ((s3))。 注意:如果參數(shù) str為空( null),則 concat方法不創(chuàng)建新串,而僅僅返回當(dāng)前串, 67 String類常用方法 (續(xù) ) 10. public String replace(char oldChar, char newChar) 將 String對象中所有的 oldChar字符替換為newChar, 返回替換后的新串 。 68 例 :驗證回文串 ? public class CheckPalindrome ? { ? public static void main(String[] args) ? { ? // Prompt the user to enter a string ? (Enter a string: )。 ? up。 例如: StringBuffer s=new StringBuffer( )。 74 StringBuffer類常用方法 1. public int length( ) 返回字符串的長度 2. public int capacity( ) 返回緩沖區(qū)大小 3. public void setLength(int newLength) 指定對象的長度 , 將對象的內(nèi)容進(jìn)行裁減 。 (Length=+( ))。 (20)。)。 // 輸出 true (s1)。 例如: StringBuffer str=new StringBuffer( Java!)。 ? ( + 39。\n39。 ? else ? ( +i*j)。 StringTokenizer fenxi=new StringTokenizer(we ,are 。 (str)。 } }
點擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1