WON.dev
chapter04 : Triangle 본문
package org.joonzis.ex;
public class Ex04_Triangle {
int width;
int height;
void setFields(int w, int h) {
width = w;
height = h;
}
// 아래 두 calcArea 메소드가 오버로딩 되지 않은 이유
// -> 메소드 이름은 같으나, 매개변수가 다르지 않다.
int calcArea() { // 일부러 오류 냄
return width * height / 2;
}
double calcArea() {
return width * height / 2.0;
}
}
'JAVA > chapter07_method' 카테고리의 다른 글
Test . method (0) | 2023.05.26 |
---|---|
Test . oper (0) | 2023.05.26 |
chapter03 : Recursiveclass (0) | 2023.05.26 |
chapter02 : local / localmain (0) | 2023.05.26 |
chapter01 : rect / rectmain (0) | 2023.05.26 |