Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String[x][y]...How can I know the size of my array??

Status
Not open for further replies.

HoMyGod

Programmer
Jul 17, 2000
59
CH
Hi,

probably a dummy question...

I have an array like this :

String[][] anArray = MyMethodThatReturnAnArray...

and I would like to know what is the size of my array...is there something like

anArray[].size or something...?

Thanks
 
Hi,
I'm new to java, but will this give you what you want?

class hello
{
public static void main(String[] args)
{
int x;
String[][] tstl = new String[5][10];

System.out.println(tstl.length + " ");// gets no of rows
for(x = 0; x < tstl.length; ++x)
System.out.println(tstl[x].length + &quot; &quot;); gets size of each row which can be sumed

}
}

I say &quot;rows&quot; because it's easier to think in rows and columns.

Pappy
You learn somrthing everyday.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top