Currently i'll try to understand extended classes in java.
What was done: I create a class and extende class for him, in extended class i create constructor with simple commands - show variables from superclass. In another file i try to create object of extended class, but i have error - "No enclosing instance of type CObj is accessible. Must qualify the allocation with an enclosing instance of type CObj (e.g. x.new A() where x is an instance of CObj)."
Code: main file
public class Demo {
public static void main (String[] args){
CObj.Co n=new CObj.Co();
n.show();
}
}
and file with classes
class CObj {
int i,k,l;
CObj summ (CObj object){
object.i*=i;
object.k*=k;
object.l*=l;
return object;
}
void show (){
System.out.println("this is super class");
System.out.println(i+" "+k+" "+l);
}
... few constructors... and exntended class
class Co extends CObj{
Co(){
super(1,2,3);
}
void show(){
System.out.println("this is extended class and overloaded meth");
super.show();
}
}
Question; what was done wrong? why i have this error and what i need to change? Or maybe i'm doing something in a bad way?