兒童動(dòng)物樂(lè)園 java定義一個(gè)動(dòng)物類,用構(gòu)造方法實(shí)現(xiàn)動(dòng)物的實(shí)例化?
java定義一個(gè)動(dòng)物類,用構(gòu)造方法實(shí)現(xiàn)動(dòng)物的實(shí)例化?公共類動(dòng)物{int height//height int weight//weight int age//age string sex//gende
java定義一個(gè)動(dòng)物類,用構(gòu)造方法實(shí)現(xiàn)動(dòng)物的實(shí)例化?
公共類動(dòng)物{int height//height int weight//weight int age//age string sex//gender公共動(dòng)物(int height,int weight,int age,字符串性){//4參數(shù)構(gòu)造法這個(gè)。身高=高度這個(gè)重量=重量此年齡=年齡這個(gè)。性=sex}public static void main(String[]args){Animal Animal=new Animal(100,60,2,“male”)/*動(dòng)物有height,weight,age和sex的屬性值*/}