jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes populating a predefined list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "populating a predefined list" Watch "populating a predefined list" New topic

populating a predefined list

Abagesh Kumar

Joined: Mar 26, 2012
Posts: 9
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 ?
John Jai

Joined: May 31, 2011
Posts: 1776
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]],...
Maganti Suryanarayana Murthy

Joined: Apr 09, 2012
Posts: 10

I havenot got you what are U1, L1, L2 etc., Please be specific

Maganti Surya
I agree. Here's the link: http://aspose.com/file-tools
subject: populating a predefined list
It's not a secret anymore!