Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 18th, 2005, 9:01 PM   #1
quantalfred
Newbie
 
Join Date: Jan 2005
Posts: 21
Rep Power: 0 quantalfred is on a distinguished road
Question about LinkedList [Solved]

Say S ={2,1,3} is a LinkedList. How could I change S.get(2) to int?

Last edited by quantalfred; Feb 19th, 2005 at 12:35 PM.
quantalfred is offline   Reply With Quote
Old Feb 19th, 2005, 2:11 AM   #2
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
int myInt = Integer.parseInt(S.get(2));

or somthing very, very similar to that. In any case, check out the Integer class.
If you're using 1.5, Java automatically wraps ints into Integer, in order to store them on thie LinkedList (as the list stores its data as Object, which doesnt like primatives.)
So, the LinkedList should return an Integer, which you unwrap with Integer.parseInt
ZenMasterJG is offline   Reply With Quote
Old Feb 19th, 2005, 12:35 PM   #3
quantalfred
Newbie
 
Join Date: Jan 2005
Posts: 21
Rep Power: 0 quantalfred is on a distinguished road
Quote:
Originally Posted by ZenMasterJG
int myInt = Integer.parseInt(S.get(2));
Thanks. That's ok now.
quantalfred is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC