본문 바로가기
  • Adillete
【♣부트 캠프♣】/▷부캠- 에러 모음

[24.05.30-10일차] No enclosing instance of type TestD is accessible. Must qualify the allocation with an enclosing instance of type TestD (e.g. x.new A() where x is an instance of TestD).

by 아딜렛 2024. 5. 30.

No enclosing instance of type TestD is accessible. Must qualify the allocation with an enclosing instance of type TestD (e.g. x.new A() where x is an instance of TestD).

 

circle을 찾아야함 

class Circle extends TestD{//부모꺼는 다 내꺼

	private int r;//10

	protected static final double PI=3.14; //상수는 초기화를 꼭 해줘야한다.

	public Circle(int r) {// 기본 생성자 없으므로 int r로 오버로딩된 생성자로 객체 생성을 해줘야한다.

		super("원");//부모의 오버로딩된 생성자를 찾아갈거다.

		this.area =r;
	}
	public void circleArea() {

		area = (double)r*r*PI; // 원의 면적 구하기
	}
}
//} //한개 더있어서 다 없었음

 

▶해결


문제:  배열 객체 생성에서 나오는 오류 왜이러지

Type mismatch: cannot convert from Record[] to Record

	Record rec; //배열만들껀데 하나도 안정함 ▶여기가 오류네~~
	public void set() { //인원이 2명이든 상관없네

		do {
			System.out.println("인원수?");
			inwon = sc.nextInt();

		}while(inwon<1 || inwon>10);

		//배열 객체 생성
		rec = new Record[inwon];///앞에 Record rec썼으니까 쓸수 있음  [inwon]배열을 생성하겠다.
		//인원수 만큼 배열 생성(배열 메모리 할당, 배열 객체 생성) 
	}

▶해결

Record[] rec; //Record rec; →Record[] rec; 으로 변경함 오류 잡았음

 


Syntax error on token "print", AnnotationName expected after this token

 

????