일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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://tecoble.techcourse.co.kr/post/2021-08-07-logback-tutorial/
- 국회의원 & 높으신 분들 어록
- https://minkwon4.tistory.com/161
- Today
- Total
목록java/예제 (19)
OPEN between Secret
class Person { String phone; public void setPhone(String phone) { this.phone= phone; } public String getPhone() { return phone; } } class Professor extends Person { public String getPhone() { // Person의 getPhone()을 오버라이딩함 return "Professor : " + super.getPhone(); // super.getPhone()은 Person의 getPhone()을 호출 } } public class Overriding { public static void main (String [] args) { Professor a = new..
class DObject { public DObject next; public DObject() { next = null; } public void draw () { System.out.println("Dobject draw"); } } class Line extends DObject { public void draw() { // 메소드 오버라이딩 System.out.println("Line"); } } class Rect extends DObject { public void draw() { // 메소드 오버라이딩 System.out.println("Rect"); } } class Circle extends DObject { public void draw() { System.out.println("Cir..
class Person { } class Student extends Person { } class Researcher extends Person { } class Professor extends Researcher { } public class InstanceofExample { public static void main ( String [] args) { Person jee= new Student(); Person kim = new Professor(); Person lee = new Researcher(); if( jee instanceof Student) //jee는 Student 타입이므로 true System.out.println("jee는 Student 타입"); if( jee instanc..
class Person { int age; public String name; protected int height; private int weight; public void setWeight(int weight) { this.weight = weight; } public int getWeight () { return weight; } } public class Student extends Person{ void set() { age = 30; name = "홍길동"; height = 175; setWeight(99); System.out.println(age ); System.out.println(name); System.out.println(height); System.out.println(getWe..
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..
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..
public class ArrayParameter { static void replaceSpace(char a[]){ for(int i = 0; i
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); } } --------------------..