• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

distribute tokens (cards)..

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi... i'm new to java...

I have a string input like this --

String input = "D-K,D-Q,D-J,D-10,D-9,D-8,D-7,D-6,D-5,D-4,D-3,D-2,D-1";

I'm done tokenizing the string.

and i have to make an output like this..



list 1: D-K

list 2: D-Q, D-9

list 3: D-J, D-8, D-6

list 4: D-10, D-7, D-5, D-4



excess: D-3, D-2, D-1

please help me with the code... thanks!



 
Marshal
Posts: 76885
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why on earth do you want a 7-element array of Lists?
 
Jenny Calderon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i just put 7 as a value to eliminate errors...
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You know how to use ArrayList but still didn't think of a List<List<String>>? In other words, but your ArrayList in another List.
 
Campbell Ritchie
Marshal
Posts: 76885
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't go guessing values, producing a 7 out of thin air confuses the reader. It should readYou realise that creating an array of Lists precludes you from giving the Lists an actual type parameter (generics) and loses you the type-safety of generics? That is why Rob's suggestion is so much better.
reply
    Bookmark Topic Watch Topic
  • New Topic