Object creation in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Object creation in java

I am facing this error "Exception in thread "main" java.lang.Error:Unresolved compilation problem: No enclosing instance of type Arsh is acessible. Must qualify the allocation with an enclosing instance of type Arsh(e.g. x.new A() where x is an instance of Arsh). at Arsh.main(Arsh.java:35)" import java.util.Scanner; public class Arsh{ public class Animal{ private... private... getter setter public static void main(String[]args){ int ch; Animal dog=new Animal();(error here) Animal cat=new Animal();

6th Dec 2016, 3:10 PM
Arshad Ali
Arshad Ali - avatar
2 Answers
+ 2
it says in problem view No enclosing instance of type Arsh is acessible. Must qualify the allocation with an enclosing instance of type Arsh(e.g. x.new A() where x is an instance of Arsh). at Arsh.main(Arsh.java:35)
7th Dec 2016, 7:44 AM
Arshad Ali
Arshad Ali - avatar
0
You havea compilation failure because of this problem. You should see a compilation error showing in the Problems view that needs fixing.
6th Dec 2016, 4:01 PM
Vipul Walia
Vipul Walia - avatar