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; } }

18th Oct 2017, 12:32 PM
oyl
1 Answer
+ 2
seems okay :)
18th Oct 2017, 1:09 PM
‎ɐısıօՏɐ
‎ɐısıօՏɐ - avatar