• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help Needed, Finding a specific Integer, within an Arraylist<String>

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have an array list

and within this array list i have stored several integers in a String

I am wondering what Method is possible to find aID, giving a specific ID that is to be found,

that is my attempt, but i get the error int cannot be converted to CharSequence
 
Saloon Keeper
Posts: 15510
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sean, welcome to CodeRanch!

I think the best way is to first convert every string in the list to a strongly typed object, so you can have a Map<Integer, Order> ordersByID, and you can just do stuff like orders.get(specificID).getTotalCost().

So first design an Order class, and write a method that turns a String into an Order.
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I reformatted your code and added code tags. When you post code in the future, please add code tags yourself, and use the "Preview" button to make sure your formatting is correct before you submit your post.
 
Sean McCormack
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stephen, will give it a go! And here i was thinking Bartender/Programmer was a unique occupation, Is there any time we go stress free? haha
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Work every day and every night ;)
reply
    Bookmark Topic Watch Topic
  • New Topic