Frog is cry
메소드 오버로딩 본문
package method_overloding;
public class Calculator {
double areaRactangle(double width) {
return width * width;
}
double areaRactangle(double width, double height) {
return width * height;
}
// 메소드 이름은 같아도 매개변수가 다른것을 오버로딩이라함
// 사용이유 : 다양한 형태의 매개값을 두고 실행하기 위하여
}
package method_overloding;
public class Calculator_Ex {
public static void main(String[] args) {
Calculator myCalc = new Calculator();
double result = myCalc.areaRactangle(10);
double result2 = myCalc.areaRactangle(10, 10);
System.out.println("정사각형의 넓이 " + result);
System.out.println("정사각형의 넓이 " + result2);
}
}
Comments