Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with arraylist

 
saidi Bandi
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about List<Object> aList = new ArrayList<Object>();?
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Pie
Posts: 50251
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic