java - how do you know what parameters go inside the parentheses when creating a new object? -
i in process of learning java programming. see code looks this:
shape ball= new shape();.// takes no parameter shape ball= new shape(1,2); //takes parameter my question is, when object has multiple constructors take different paramaters, how know constructor use?
look @ documentation class. that's surefire way know. shape class provided has 2 constructors:
shape() //default no-args { //do } shape(int a, int b) { //do , b }
Comments
Post a Comment