• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using getLength() on a character array  RSS feed

 
Matt Hazan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am VERY new to JAVA and I was wondering if someone can please help me understand how to use getLength? I went on the JAVA website and saw an example, but it seemed over complicated.

if for example I have a character array as follows: char word[]={'M','U','S','I','C'}; ( OR ANY OTHER WORD IN THE ARRAY)

How can I store the length of the word a integer variable using getLength?
Can someone please give me a simple coded example?


I GREATLY APPRECIATE IT!
Thanks in advance!
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no getLength() method on a Java array. There is a length property. Is that what you mean? There is plenty of sample code on the web. Here's a link to one: http://www.learn-java-tutorial.com/Java-Arrays.cfm. FYI, I found it by Googling java 6 array tutorial.
 
Prakash Krsihnan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There no getLength() API for array in Java instead length of array can be identified using length

Below code will give the length of array

 
Campbell Ritchie
Marshal
Posts: 56592
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Reilly wrote: . . . There is plenty of sample code on the web. Here's a link to one: . . .
That's a nice tutorial.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!