• 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

populating a predefined list

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a string 0609|1|2834.56150|07710.32664|

I can parse using split .

Is it possible to have a predefined lsit or something which will hold

U1 = 1
L1 = 3
L3 = 2
L4 = 4

and will populate it with the exact values grabbing the substring from position( 1, 3, 2, 4).

U1 = 0609


L1 = 2834.56150


L3 = 1


L4 = 07710.32664


Any ideas on how to do this ?
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The String class split() method returns you a String array. Suppose the array variable is str then you already have below values if you split using '|'.


You can store the combination as a combination int array ->


and print the str[combination]. Check with the array's length to avoid ArrayIndexOutOfBoundsException.

edit - by str[combination] I meant str[combination[0]], str[combination[1]],...
 
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I havenot got you what are U1, L1, L2 etc., Please be specific

 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic