일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- https://minkwon4.tistory.com/161
- https://tecoble.techcourse.co.kr/post/2021-08-07-logback-tutorial/
- 국회의원 & 높으신 분들 어록
- Today
- Total
목록My story (831)
OPEN between Secret
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..
>>>클래스의 접근 지정자 접근 지정자를 생략하면은 default 접근 지정자로 자동 선언 되는되, 이 경우는 같은 패키지 내에 있는 클래스들만 접근이 가능하다. >>>멤버 접근 지정자 비공개를 의미함. -> 같은 클래스 내부 멤버에 의해서만 접근이 가능. 어떤 다른 클래스에서도 접근할수 없다. -> 동인 패키지내의 다른 클래스더라도 접근이 불가능하다. 3. protected 멤버 -> 보호된 공개를 의미함. -> 같은 패키지 내의 모든 클래스에서 접근이 가능. -> 다른 패키지의 클래스더라도 이 클래스를 상속받은 자식일 경우는 접근이 가능. 4. default 멤버 -> 접근 지정자 선언이 생략될 경우, default로 선언되었다고 함 -> 동인한 패키지 내에 있는 모든 클래스에서 접근가능. ex) c..
public class Book { String title; String author; int ISBN; public Book(String title, String author, int ISBN) { this.title = title; this.author = author; this.ISBN = ISBN; System.out.println(title + author + ISBN); } public Book(String title, int ISBN) { this(title, "Anonymouse" , ISBN); } public Book(){ this(null, null, 0); System.out.println("생성자가 호출되었음;"); } public static void main(String [] ..
public class ArrayParameter { static void replaceSpace(char a[]){ for(int i = 0; i
import java.io.*; class Yuen2 { int cnt1=0, cnt2=0; boolean b1 = true; public void Calc() { while(true) { try{ int i = System.in.read(); if(i == 32){ if(b1 == true){ cnt1 +=1; b1 = false; } else if(b1 == false) { cnt2 +=1; b1 = true; } } else if(i == 13){ System.out.println("left" + cnt1); System.out.println("right" +cnt2); System.out.println("총 합계" + (cnt1 + cnt2)); break; } }catch(Exception e)..
import java.awt.*; import java.awt.event.*; class Yuen extends Frame { int cnt1 = 0; int cnt2 = 0; boolean bl = true; TextArea ta; public Yuen () { setLayout(new FlowLayout() ); Panel p1 = new Panel(); Label la1 = new Label("스페이스바 입력 개수 출력하기 "); p1.add(la1); add(p1); Panel p2 = new Panel(); ta = new TextArea( "",5, 20,TextArea.SCROLLBARS_NONE); p2.add( ta ); add( p2 ); ta.addKeyListener( new Key..
import java.util.Scanner; class Goods { private String name; private int price; private int numberOfStock; private int sold; Goods(String name, int price, int numberOfStock, int sold) { this.name = name ; this.price = price; this.numberOfStock = numberOfStock; this.sold = sold; } String getName() { return name; } int getPrice () { return price; } int getNumberOfStock(){ return numberOfStock; } i..
public class MyExp { int base; int exp; int getValue() { int res=1; for(int i = 0 ; i < exp ; i++) res = res * base; return res; } public static void main(String[] args){ MyExp num = new MyExp(); num.base = 2; num.exp = 3; MyExp num2 = new MyExp(); num2.base = 3; num2.exp = 4; System.out.println("2의 3승 = " + num.getValue()); System.out.println("3의 4승 = " + num2.getValue()); } } -----------------..
public class Goods { String name; int price; int numberOfStock; int sold; public static void main(String[] args){ Goods camera = new Goods(); camera.name = "Nikon"; camera.price = 400000; camera.numberOfStock =30; camera.sold = 50; System.out.println(camera.name); System.out.println(camera.price); System.out.println(camera.numberOfStock); System.out.println(camera.sold); } } --------------------..