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

正文內容

抽象類和接口ppt課件-資料下載頁

2025-01-05 11:51本頁面
  

【正文】 tive Object clone() throws CloneNotSupportedException。 class A implements Cloneable{ protected A clone(){ try{ return (A)()。 } catch (CloneNotSupportedException ex){ return null。 } } } public class T{ public static void main(String[]s){ A a1=new A()。 A a2=()。 } } 想用 clone 類 A需要: (1)實現(xiàn) Cloneable (2)覆蓋 Object中的clone()方法 至少是 protected 返回的是 A,是 Object的子類,也能覆蓋 class A implements Cloneable{ protected A clone() throws CloneNotSupportedException{ return (A)()。 } } public class T{ public static void main(String[]s) throws CloneNotSupportedException{ A a1=new A()。 A a2=()。 } } class B{} class A extends B implements Cloneable{ protected A clone() throws CloneNotSupportedException{ return (A)()。 } } public class T{ public static void main(String[]s) throws CloneNotSupportedException{ B a1=new A()。 A a2=()。 } } 編譯錯 。 B類沒有實現(xiàn) Cloneable接口,沒有重寫 clone()方法 何時用抽象類?何時用接口? 抽象類:“強是一種關系” 類繼承 接口:“弱是一種關系” 不同類的對象共有的屬性、行為 動物 哺乳動物 非哺乳動物 電器 家用電器 非家用電器 壽命 P278 接口與抽象類 變量 new實例化 構造方法 具體方法 抽象方法 其它方法 抽象類 無限制 否 有,由子類可調用 可以有 子類若具體,必須實現(xiàn)全部抽象方法 無限制 接口 隱含 public static final 否 無 不能有 子類必須實現(xiàn)全部抽象方法 隱含public abstract 將基本數(shù)據(jù)類型值處理為對象 Double dObject=new Double()。 Integer iObject=new Integer(1)。 long l=()。 int i=()。 Comparable Object Number Character Boolean Double Float Long Integer Short Byte 基本類型和包裝類之間的自動轉換 Integer intObject=2。 等價于 Integer intObject=new Integer(2)。 Integer[] iArray={1,2,3}。 自動執(zhí)行了 Integer iObject=(“12”)。//字符串變整數(shù)并構建對象 (iArray[0])中,自動將 iArray[0]轉換為 int類型 (“12”) //返回 12,字符串轉換成整數(shù) (“”) //返回 ,字符串轉換成 double型 iArray[0]=new Integer(1)。 iArray[1]=new Integer(2)。 iArray[2]=new Integer(3)。
點擊復制文檔內容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1