I have a string like _a01_a02_a03_ and another string like
_2_1.5_4_ as input.I want to extract a01,a02... to a string
array and 2,1.5,etc to a double array with a01 corresponds
to 2 and a02 to 1.5 etc. Need code in core java.. Can you do
it?
Answer / sam
final String str1 = "_a01_a02_a03";
final String str2 = "_2_1.5_4";
final String[][] strArray = new String[3]
[2];
final StringTokenizer objST1 = new
StringTokenizer(str1,"_");
final StringTokenizer objST2 = new
StringTokenizer(str2,"_");
int iCnt=0;
while (objST1.hasMoreTokens())
{
objST2.hasMoreTokens();
strArray[iCnt][0] = (String)
objST1.nextToken();
strArray[iCnt++][1] = (String)
objST2.nextToken();
}
for(iCnt=0;iCnt<3;)
System.out.println(strArray[iCnt][0]
+" "+strArray[iCnt++][1]);
| Is This Answer Correct ? | 17 Yes | 0 No |
Which class is the superclass for every class in java programming?
Why super is first line in java?
What is json parser in java?
What is the importance of finally block in exception handling?
What are streams?
Which methods cannot be overridden in java?
what is the need of the Ajax?
What is singleton service?
Can you run java program without main method?
What is the difference between jsp and servlet?
What is the generic class?
How will you reverse a singly-link list?
0 Answers Akamai Technologies,