0
Constructor question(beginner)
am i using constructor correctly here?i have just learnt it tdy. class Myclass{ public static void main(String[]args){ Pokemon pikachu=new Pokemon(); Pokemon charmander=new Pokemon("fire"); System.out.println(pikachu.type); System.out.println(charmander.type); } } class Pokemon{ String type; Pokemon(){ type="electric"; } Pokemon(String x){ type=x; } }
1 ответ
+ 2
seems okay :)