By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,468 Members | 1,865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,468 IT Pros & Developers. It's quick & easy.

array of Strings

P: n/a
hi,

I have a small problem.
I have a Array of Strings.
See code below..
<snip>
File f = new File("some directory");
String[] names = f.list();
<snip>

How do i find out the number of Strings in the array
name.
String.length() gives me the length of any 1 String and
the total number of Strings

TIA
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Tejus wrote:
See code below..
<snip>
File f = new File("some directory");
String[] names = f.list();
<snip>

How do i find out the number of Strings in the array
name.


Read the names.length attribute, i.e.

String[] names = f.list();
int namesLength = names.length;

--
Jonas Kongslund
Jul 17 '05 #2

P: n/a
ct******@rediffmail.com (Tejus) wrote in message news:<4c**************************@posting.google. com>...
hi,

I have a small problem.
I have a Array of Strings.
See code below..
<snip>
File f = new File("some directory");
String[] names = f.list();
<snip>

How do i find out the number of Strings in the array
name.
String.length() gives me the length of any 1 String and
the total number of Strings

TIA

int numberOfStrings = names.length;
Jul 17 '05 #3

P: n/a
On 24 Nov 2003 23:35:10 -0800, ct******@rediffmail.com (Tejus) wrote:
hi,

I have a small problem.
I have a Array of Strings.
See code below..
<snip>
File f = new File("some directory");
String[] names = f.list();
<snip>

How do i find out the number of Strings in the array
name.
String.length() gives me the length of any 1 String and
the total number of Strings

TIA


For any array, you can get the number of elements in the array by

array.length

So for you, you can do:

int n = names.length;
If you want to contact me, you can send me mail via
web browser: http://da*****@googlenews.test.xhome.us
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.