English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

The actual code is:

String[] pieces=whole.split("^");

I need to iterate through the array, but there doesn't seem to be a method similar to ArrayList's size( ) that will give me the size/length.

2006-11-29 13:11:09 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

**THANKS SO MUCH; I knew I had done this a million times but I was drawing a blank!

2006-11-29 13:37:14 · update #1

3 answers

int noOfElements = pieces.length;

use the var noOfElements for looping...

HTH

2006-11-29 13:33:36 · answer #1 · answered by SmartSpider 4 · 1 1

Like almost everything in Java, arrays are handled by a class behind the scenes. The array class has a public final field named "length" which contains the size of the array.

pieces.length

2006-11-29 13:33:41 · answer #2 · answered by watsonc64 3 · 0 0

String pieces[] = whole.split("^");

//use the length attribute to get the number
//of elements in an array
for(int i = 0; i < pieces.length; i++ ) {
System.out.println("piece: " + pieces[i]);
}

2006-11-29 13:34:58 · answer #3 · answered by Steve A 2 · 0 0

fedest.com, questions and answers