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

正文內(nèi)容

第一章java的類-全文預(yù)覽

2024-09-29 09:01 上一頁面

下一頁面
  

【正文】 c float area() { return *r*r。 } } 65 Java中的抽象類、接口和程序包 ? 利用接口可實(shí)現(xiàn)多重 繼承 (可同時實(shí)現(xiàn)多個接口) ? 接口的作用和抽象類 類似 ,指定原型 ,不直 接定義方法的內(nèi)容 . ? 關(guān)鍵字 implement用 來實(shí)現(xiàn)方法 ,即在使用時要用給出方法的實(shí)際內(nèi)容 ? 接口中的方法和變量 ? 是 public的 interface Stack { void push(object x)。// 具體內(nèi)容 } } 66 Java中的抽象類、接口和程序包 ? 程序包: 相當(dāng)于其它語言中的庫函數(shù) ? 打包 package Graphics。} ? 使用程序包中的類要用 import命令 .表示路徑 ,*表示使用包中的所有類 ? import ; ? import .*; io java FileInputStream 67 對象的構(gòu)造函數(shù) ? 使用 new來做內(nèi)存配置 class Demo1 //數(shù)組的配置 { public static void main(String args[]) { int array[][]。} class Demo2 { public static void main(String args[]) { myClass obj。 Point() { x =0。 Point point_B=new Point(5,7)。 Circle(int r) {=r。 C:\...\myclasses import .*。 ? private String senderStreet。 ? private String receiverName。 ? private String receiverZip。 ? private String receiverCity。 ? private String senderState。 import .*。} } 71 ? super指這個對象的父類 ? super用來引用父類中的方法及變量數(shù)據(jù) . ? public class apple extends fruits ? { public apple(int price) ? { super(price)。 (this)。} Point(int new_x,int new_y) { x=new_x,y=new_y。 ()。 array[1][4]=5。} class Circle {…。} class A extends Applet implements Stack { void push(object x) { …。 Rectangle (int w, int h){ width=w,height=h。} class Circle extends Shape { public int r。 } } 63 Java中的抽象類、接口和程序包 ? 假設(shè)有若干個 Circle,以及若干個 Rectangle,希望計(jì)算它們的總面積 ,直截了當(dāng)?shù)淖龇ㄊ菍⑺鼈兎謩e放到兩個數(shù)組中 ,用兩個循環(huán) ,加上一個加法 ,這種做法是不漂亮的 ? 如果還有其它形狀 ,triangle,ellipses等 ,上述方法顯得“累贅” ,我們希望有一種統(tǒng)一的表示 ,例如用一個數(shù)組 shape[],接受所有的形狀 ,然后用 ? for (i=0。 Circle(int r) {=r} //this指 這個對象的 public int area() {return 3*r*r。 ? (mystring)。 ? public static void main(String args[]) ? { (mystring)。 ()。} class C extends B { void print_out() { (“data_a= ”+data_a)。 =10。 ()。 protected void show() { (“pro_i=” +pro_i。 ()。 class ABC { public int pub_i=5; public void show)() { (“pub_i”+pub_i)。 ()。}} 44 Java中的類、方法和變量 ? TrashCar中繼承了 Car中的兩個方法 class CarDemo { public static void main(String args[]) { TrashCar DemoTrashCar=new TrashCar()。 } } class TrashCar extends Car { int capacity。 ()。 void set_number(int car_num) { car_number=car_num。 例 :StringBuffer sb=new StringBuffer(“Drink Java!”)。 ? boolean result=(“this is a 特 test”)。 ? String類與其它類型的轉(zhuǎn)換 ? 例 1:將實(shí)型數(shù)轉(zhuǎn)換成字符串 ? (())。i。 37 Java類型系統(tǒng) ? 能夠動態(tài)取得的內(nèi)存有兩種 ,一種是對象實(shí)體 ,一種數(shù)組 . ? Java用 new申請內(nèi)存 ,不需要自己釋放不用的內(nèi)存 . ? 在 Java中,定義數(shù)組時不必給出數(shù)組的大小,因?yàn)?Java的數(shù)組是動態(tài)分配的。 int day。 Boolean isAlived。 import .*。 } } 編輯存盤: 主類名 (extends Applet)和文件名一致 編譯代碼 : javac 編寫 HTML文件 : 29 你的第一個 Java程序 ?運(yùn)行 applet程序 : 1. appletviwer 2. 在瀏覽器中運(yùn)行 ? 運(yùn)行結(jié)果 : Hello World! htmlbody applet code=“” width=200 height=100 /applet/body/html 30 你的第一個 Java程序 ? 理解程序 1. import語句相當(dāng)于 C語言中的 include每 2. 每一個 applet都是 用 extends繼承 3. applet中沒有 main方法 import 。 }} 27 你的第一個 Java程序 4. 命令行參數(shù)的獲取 c:java HelloWorldApp myjava! 6. 字符串的拼接 public class HelloWorldApp { public static void main(String args[]) { (“Hi, ”+args[0])。 c:\myclasses。 } } 12 有關(guān)面向?qū)ο蟮母拍? ? 什么是方法的重載 (多態(tài)性 )? ? 在同一個類中至少有兩個方法用同一個名字,但有不同的參數(shù)。 int speed。 push_break() { … } add_oil() { … } } class Trash_Car extends Car { double amount。} 8 有關(guān)面向?qū)ο蟮母拍? ? 什么是封裝 ? ? 封裝把對象的所有組成部
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1