for example:
public class Item {
/*public void hiFromItem() {
System.out.println("hello from super");
}*/
}
public class Laptops extends Item{
public void hiFromLaptops() {
System.out.println("hello from child");
}
/**
* @param args
*/
public static void main(
String[] args) {
// TODO Auto-generated method stub
Item it = new Laptops();
it.hiFromLaptops();
//it.hiFromItem();
System.out.println(it);
}
}
Above gives compelation error. However,
public class Item {
/*public void hiFromItem() {
System.out.println("hello from super");
}*/
}
public class Laptops extends Item{
public void hiFromLaptops() {
System.out.println("hello from child");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Item it = new Laptops();
((Laptops) it).hiFromLaptops();
//it.hiFromItem();
System.out.println(it);
}
}
compiles. So maybe this is a casting situation.