Sorry, may seem like a dumb question, but I haven't seen anyone else ask it on here. I'm trying to create a stack of doubles, by casting them as I pop them out. The only trouble is that the compiler (eclipse) won't let me cast an object to a double. Any suggestions?

Thanks,
Nate

Recommended Answers

All 2 Replies

Again, sorry, nevermind.

Double.parseDouble((String)(stack.lastElement()));

duh...

To cut down on parenthesis you could call toString():

stack.lastElement().toString()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.