• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Using getLength() on a character array

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Marshal
Posts: 76395
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You've gotta fight it! Don't give in! Read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic