How do you refer to a class instance? It's done using a variable. A variable must have exactly one type explicitly declared for as long as the variable exists.
So you want a variable that can...
Type: Posts; User: helloworld922
How do you refer to a class instance? It's done using a variable. A variable must have exactly one type explicitly declared for as long as the variable exists.
So you want a variable that can...
I think you're confusing the actual instances vs. variables.
All variables must have a type in Java. This is fixed and must be explicitly declaring it, a variable will always hold a value/instance...
You're saying 2 things:
Object o
This declares a variable. It has a type Object. That means it can hold an instance of the Object class, or any class which extends the Object class.
o =...
area isn't a method of the Object class.
What does it even mean to take the area of an Object? What if that Object is a String?
The compiler has no way of knowing what type of object the...