aspose file tools*
The moose likes Beginning Java and the fly likes Comparable again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Comparable again" Watch "Comparable again" New topic
Author

Comparable again

Andrew Lit
Ranch Hand

Joined: Jul 01, 2002
Posts: 135
Hi,
Comparable c = new Integer(1);
int i = (int)c;// compiler error cannot cast
Is there a way to get that integer i put there?
thank you in advance.
Rob Misek
Ranch Hand

Joined: Sep 24, 2002
Posts: 41
int i = (int) c
should be:
int i = c.intValue();


<a href="http://www.tangosol.com" target="_blank" rel="nofollow">www.tangosol.com</a><br /><a href="http://www.tangosol.com/coherence.jsp" target="_blank" rel="nofollow">Coherence:</a> Easily share live data across a cluster!
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Have you looked at the API documentation for the java.lang.Integer class?
(I could give you the answer, but it's better for you to learn where to find it yourself.)


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729

Beat me to it again Ron, but it was close that time.
[ October 03, 2002: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Andrew Lit
Ranch Hand

Joined: Jul 01, 2002
Posts: 135
Thank you for your posts. You helped me a lot.
Originally posted by Ron Newman:
Have you looked at the API documentation for the java.lang.Integer class?


Yes i did, but for some reasons i couldn't get what i need. My fault, sorry.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparable again