Ello,
If class "widget", extends "something", is it possible to create an instance of something then use it it as a widget?
Here's the code I'm trying to get to work:
VB Code:
class universe { public static void main(String[] args) { something whoKnows; whoKnows = new widget(); System.out.println(whoKnows.getWeight()); } } class something { public int weight=2; } class widget extends something { public int getWeight() { return weight; } }
Output:
Thanks!C:\JAVA\INHERI~1>javac universe.java
universe.java:8: cannot find symbol
symbol : method getWeight()
location: class something
System.out.println((widget)whoKnows.getWeight());
^
1 error





Reply With Quote