일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 국회의원 & 높으신 분들 어록
- https://tecoble.techcourse.co.kr/post/2021-08-07-logback-tutorial/
- https://minkwon4.tistory.com/161
- Today
- Total
OPEN between Secret
class Point { int x, y; //한 점을 구성하는 x,y 좌표 void set(int x, int y) { this.x = x; this.y = y; } void showPoint() { // 점의 좌표 출력 System.out.println("(" + x + "," + y + ")"); } } public class ColorPoint extends Point { //Point를 상속받은 ColorPoint 선언 String color; void setColor(String color) { this.color= color; } void showColorPoint(){ System.out.println(color); //컬러 점의 좌표 출력 showPoint(); //Point 클래스의 s..
final키워드가 사용될수 있는 곳은 세군데이다. 1. final 클래스 -> final을 클래스 앞에 사용하면 다른 클래스에서 상속받을 수 없음을 말해주는 것이다. 2. final 메소드 -> final을 메소드 앞에 붙이면 이 메소드는 오버라이딩(재정의) 될수가 없다는 것이다. -> 즉, 오버라이딩 못하게 하고 무조건 상속 받아 사용하도록 하고자 할때 쓰인다. 3.final 필드, 상수 정의 -> 상수를 정의할때 사용하는 방법이다. -> 상수 필드는 선언시에 초깃값을 지정하여야 한다.(한번 정의되면 값을 변경할수 없다.) -> final 키워드는 static과 함께 사용하여 프로그램 전체로 공유하여 사용할 수 있는 상수를 만들수 있다.
class CurrencyConverter { private static double rate; //한국 원화에 대한 환율 public static double toDollar(double won) { return won/rate; //한국 원하를 달러로 변환 } public static double toKWP(double dollar) { return dollar * rate; // 달러를 한국 원화로 변환 } public static void setRate(double r) { rate = r; } } public class StaticMember { public static void main(String [] args) { CurrencyConverter.setRate(1121); System.ou..