aspose file tools
The moose likes Beginning Java and the fly likes length function  for string Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "length function  for string" Watch "length function  for string" New topic
Author

length function for string

Rajesh Veluchamy
Ranch Hand

Joined: Jan 15, 2008
Posts: 47
hi,
For static data, the below code is fine,


but in runtime if the length of data is reduced, it throws exception
i have read something like length function

may be "data.length"

Thanks to all, in advance


-Rajesh.V<br /> Software Consultant
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

String have a length method. And arrays have a length property. See the JavaDocs for more.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32675
    
    4
I think you should have given a bit more detail, Paul.

You could write "for(int i = 0; i < data.length; i++). . ." or "for(int i = 0; i < myString.length(); i++). . ."

but for an array, if you simply want to go through all the elements, use the "enhanced for" loop, (sometimes called the for-each loop), but you can't say "c = anything".
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: length function for string
 
Similar Threads
args.length
validating multibyte characters
file.length RandomAccessFile
modifiying jquery plugins to add ontopic events
java.lang.OutOfEMemoryError