This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Problem with arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with arraylist" Watch "Problem with arraylist" New topic
Author

Problem with arraylist

saidi Bandi
Ranch Hand

Joined: Apr 07, 2007
Posts: 57
my project is developed in java1.4, now we are upgarding with 1.5, for this i am getting th eproblem with arrayList

as of my project , ArrayList is holding interger values as well as string type values.

please tell me,how could above scenario is possible in java 1.5(generics concepts)?

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

what about List<Object> aList = new ArrayList<Object>();?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

If you are upgrading to 1.5, then you are not forced to use generics. You can leave your current implementation untouched. But still if you want to or are told to use generics, then you can do what seetharaman told...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ankit Garg wrote:If you are upgrading to 1.5, then you are not forced to use generics.


Well Ankit. but if you not use generic ,you will get warning .it looks bad when you revise the code
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874




Ankit Garg wrote:If you are upgrading to 1.5, then you are not forced to use generics.

seetharaman venkatasamy :
Well Ankit. but if you not use generic ,you will get warning .it looks bad when you revise the code



Not bad considering none screws up the legacy applications.. It takes days to change and days to test... i restrain from it..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
You are all right! It is a bad idea to ignore compiler warnings . . . but it is probably a worse idea to change code which already works correctly.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4168
    
  21

Except the fact that the List is holding two different data types, Strings and Integers, which suggests a better storage mechanism is needed - why does your list contain two different data types? How are they related? Would it be better to store them in a manner that better represents the relationship between the Integer and String values?


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with arraylist
 
Similar Threads
Vote here: I'm studying for the SCJP 1.5 exam
values for select tag from the database
to find the size occupied by arraylist in kilobytes - i want to find the size of an arraylist
Double submission problem on Opera10.3
how to pass arraylist from jsp to java bean