I am a newbie to Java programming and need some help. I have an abstract class with one non-abstract method and one abstract method. From the abstract class (class A) I am calling a method of a subclass (class B) by using "this.getSize();" (I understand "this" to mean the object type that is invoking the method. So in this case -B) but I am getting an error saying this when trying to compile class A:
" Cannot find symbol - method getSize() "
I am thinking maybe this is due to the fact that I am calling this from an abstract method but I am not sure. Please help.. Thanks.
Here is my CODE:
abstract class A{
public int size()
{
return this.getSize();
}
//abstract method
abstract void grow(int f);
}
class B extends A{
private int size = 1; //default set of size
public int getSize(){ return size; }
public void grow(int factor)
{
size = size * factor;
}
}