Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter04 : Triangle 본문

JAVA/chapter07_method

chapter04 : Triangle

GAWON 2023. 5. 26. 17:49
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