Answer the question
In order to leave comments, you need to log in
How to get the value of a class field in Java from a class reference?
There is a creation of the List class, in which there is a link field.
The reference to the sheet class is passed to another variable, how to get a field from the created class from another variable.
Code example:
List lastElement = new List();
Object testLink = lastElement;
Object a = lastElement.link; //works as it should
Object b = testLink.link //does not work, but it is necessary that it works through a variable
Answer the question
In order to leave comments, you need to log in
And it won't because
<b>List lastElement</b> = new List();
<b>Object testLink</b> = lastElement;
Object a = lastElement.link; //работает так, как нужно
Object b = testLink.link //не работает, а нужно, чтобы именно через переменную работало
Object b = ((List)testLink).link
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question