The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.



Posted by sebastian on December 13, 2001 at 5:49 PM

does anyone now what the problem is when a String seems to be shorter than it really is in bytes?
I have a String s (that i get from the last element of an array of Strings)
And if i print it, it looks totally normal, say like this "hello". But when i call s.length() its 249 long.
and therefore "hello".equals(s) returns false. I cant print more than "hello".length() characters if i call println(s).
but if i convert the strings to bytes it turns out that all bytes except the 5 first (if its "hello") are 0.
Now, how can i get the String s to equal what i want it to equal, namely a String of length 5 containing the sequence "hello"?

  • String :-) Senthoor December 13, 2001 at 7:01 PM (0)

Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us