aspose file tools*
The moose likes Beginning Java and the fly likes Returning lenght of a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Returning lenght of a string" Watch "Returning lenght of a string" New topic
Author

Returning lenght of a string

Raymond Owens
Greenhorn

Joined: Jun 16, 2009
Posts: 7
How do I take a given string and return the number of characters that the string has?

For example, "character" is made up of 9 individual characters. What line of code will examine a string and answer this for me?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Have you looked at the java.lang.String JavaDocs?
Raymond Owens
Greenhorn

Joined: Jun 16, 2009
Posts: 7
David Newton wrote:Have you looked at the java.lang.String JavaDocs?


codePointCount?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Length.
Raymond Owens
Greenhorn

Joined: Jun 16, 2009
Posts: 7
I had already tried length (apparently in the wrong context) and couldn't make it work. When trying to use the less than operator, I get the error that this cannot be used with java.lang.string, int.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Without seeing any code it's hard to know where you went wrong. For example, the following works fine:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning lenght of a string
 
Similar Threads
how to read character from command line and store it string
reading digits from a double
How to get ASCII Value
maximum characters in string
ASCII value for Empty String.