Language&FrameWorks37 도형(원,직사각형)의 넓이의 합을 구하는 문제 package ch07.ex14; abstract class Shape { Point p; Shape() { this(new Point(0,0)); } Shape(Point p) { this.p = p; } abstract double calcArea(); // 도형의 면적을 계산해서 반환하는 메서드 Point getPosition() { return p; } void setPosition(Point p) { this.p = p; } } class Point { int x; int y; Point() { this(0,0); } Point(int x, int y) { this.x=x; this.y=y; } public String toString() { return "["+x+","+y+"]"; } dou.. 2011. 5. 7. 속았던 문제? 다음 실행 결과는? package ch07.ex14; class Exercise7_20 { public static void main(String[] args) { Parent p = new Child(); Child c = new Child(); System.out.println("p.x = " + p.x); p.method(); System.out.println("c.x = " + c.x); c.method(); } } class Parent { int x = 100; void method() { System.out.println("Parent Method"); } } class Child extends Parent { int x = 200; void method() { System.out.print.. 2011. 5. 7. System.arraycopy 예제 package ch07.ex14; class Exercise7_19 { public static void main(String args[]) { Buyer b = new Buyer(); b.buy(new Tv()); b.buy(new Computer()); b.buy(new Tv()); b.buy(new Audio()); b.buy(new Computer()); b.buy(new Computer()); b.buy(new Computer()); b.summary(); } } class Buyer { int money = 1000; Product[] cart = new Product[3]; // 구입한 제품을 저장하기 위한 배열 int i = 0; // Product배열 cart에 사용될 index void.. 2011. 5. 7. javadoc unmappable character for encoding MS949 Javadoc 사용시 한글 처리 unmappable character for encoding MS949 가 발생하는데 character encoding문제 VM options에 아래 사항 추가 -locale ko_KR -encoding UTF-8 -charset UTF-8 -docencoding UTF-8 2011. 4. 5. 이전 1 2 3 4 5 6 7 ··· 10 다음