package com.company;
public class UnlimitedBuffer {
//Variabels
public Object object;
//Constructor
public UnlimitedBuffer(ObjectBufferRing object){
this.object = object;
}
//Methods
public static void main(String[] args){
ObjectBufferRing obr = new ObjectBufferRing(10); //Object of another Class "ObjectBufferRing"
UnlimitedBuffer ubr = new UnlimitedBuffer(obr);
ubr.object.printArray();
}
Im to trying to access to an instance method "printArray()" of the object "object", which is saved as a class variable of another class object "ubr". But unfortunately it doesn't find the instance method "printArray()" or any other class members (variables/methods) of this object. (both classes are in the same package) Instead, i get this error output:
java: cannot find symbol
symbol: method printArray()
location: variable object of type java.lang.Object
You told Java to forget that object
was an ObjectBufferRing
with a printArray
method, when you write public Object object;
instead of public ObjectBufferRing object;
.
Java's doing what you told it to.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.