*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "populating a predefined list" Watch "populating a predefined list" New topic
Author

populating a predefined list

Abagesh Kumar
Greenhorn

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
Bartender

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
Greenhorn

Joined: Apr 09, 2012
Posts: 10

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


Regards
Maganti Surya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: populating a predefined list
 
Similar Threads
SCJP 5: Mock questions
want to display the following output?
help with .isSelected
Network Simlulation...
Getting sql error [Microsoft ][odbc microsoft access driver]numeric index out of range