Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm storing a instance of Entry class in an Object.

Entry newentry = new Entry(j, 0.0);
Object test = newentry;

How can I convert the test Object back into an Entry class to access the Entry class method getValue()?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
116 views
Welcome To Ask or Share your Answers For Others

1 Answer

Typecast it:

Entry newentry = new Entry(j, 0.0);
Entry test = (Entry) newentry;

Also, if getValue is a class method, you don't need an instance to access it, you can call it directly:

Object x = Entry.getValue();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...