목록자바 (27)
Jam's story
package days22; import java.util.Vector; /** * @author 지민 * @date 2022. 3. 20. - 오후 3:31:17 * @subject * @content * */ public class Ex01 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Buyer b=new Buyer(); b.buy(new Tv()); Computer com=new Computer(); b.buy(com); b.buy(new Audio()); b.summary(); b.refund(com); }} class Product{ int price; int bo..
필드의 접근지정자 잘못설정
No enclosing instance of type Prac is accessible. Must qualify the allocation with an enclosing instance of type 클래스를 어느 한 클래스의 내부에 썼다. 다시 분리해주니 오류가 없어졌다.

NullPointerException 객체가 없는 상태에서 사용하려고 할때 ArrayIndexOutOfBoundsException 배열-인덱스범위 초과 매개값을 주지않은 인덱스사용 밑의 사진의 곳에서 값을 줄 수 있다. NumberFormatException 문자열 -> 숫자 로 변경하는 경우에 오류 ClassCastException 상위클래스-하위클래스 인터페이스-구현클래스 간에 타입변환을 할 때, 대입된 객체가 아닌 다른 객체로 타입변환이 되면 오류 그래서 [상위| 인터페이스 ]instance of [ 하위|구현클래스 ]로 확인한 후 바꾸는 것이 좋다. package twoInterface; public class ClassCastEx { public static void main(String[] a..
package twoInterface; import java.util.Scanner; public class Test { static Scanner sc = new Scanner(System.in); static final int MIN = 2; static final int MAX = 9; public static void main(String args[]) { int D1=MIN, D2=MAX; System.out.println("시작할 단을 입력해주세요"); D1 = sc.nextInt(); while(D1MAX){ System.out.println("다시 입력해주세요 " + MIN +"단 부터" + MAX + "단 까지 입력가능합니다."); D1 = sc.nextInt(); } System.out..

특정한 관계를 맺은 경우, 클래스 내부에 선언하는 것이다 class ClassName{ class NestedClassName{ } } class ClassName{ interface NestedClassName{ } } 클래스의 멤버로서 선언되는 중첩클래스 = 멤버클래스 ->객체가 사용중이면 언제든지 재사용 가능 메소드 내부에서 선언되는 중첩 클래스= 로컬클래스 ->메소드가 실행될때만 사용할 수 있음 -멤버클래스 A$B.class A가 바깥 클래스, B가 멤버클래스 -로컬클래스 A$1B.class A가 바깥 클래스, B가 로컬클래스 인스턴스 멤버 클래스 static 필드와 메소드는 선언할 수 없다 class A{ class B{ }} A a=new A(); A.B b=a.new B(); 정적 멤버 클래..
3번 package eightInterface; public interface Soundable { String sound(); } package eightInterface; public class Cat1 implements Soundable{ @Override public String sound() { // TODO Auto-generated method stub return "야옹"; } } package eightInterface; public class Dog1 implements Soundable{ @Override public String sound() { // TODO Auto-generated method stub return "멍멍"; } } package eightInterface; ..