Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27583
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: comparison of two string |
| Date | 2014-02-24 07:59 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <leffnr$qqm$1@dont-email.me> (permalink) |
| References | <43f5b47b-d5ef-46e4-b6cd-af228c1742df@googlegroups.com> <slrnlgm8od.g8j.avl@login.logic.tuwien.ac.at> |
On 2/24/2014 5:46 AM, Andreas Leitgeb wrote:
> Navneet Mathpal <navneetmathpal93@gmail.com> wrote:
>> why equal is not comparing it although data is same ???
>
> According to your output, some of the strings in the found array
> have an extra whitespace in front. solution: use String.trim()
A hint for the future: When you're printing string values
for debugging purposes, print something that will make their
endpoints visible even if there's leading or trailing space.
For example, instead of the original
System.out.println("Best :"+best[i]);
System.out.println("Found "+found[j]);
you could try something like
System.out.println("Best: <" + best[i] + ">");
System.out.println("Found <" + found[j] + ">");
so that the output
Best: <17601089>
Found < 17601089>
would reveal the discrepancy more clearly.
--
Eric Sosman
esosman@comcast-dot-net.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
comparison of two string Navneet Mathpal <navneetmathpal93@gmail.com> - 2014-02-23 23:13 -0800
Re: comparison of two string Roedy Green <see_website@mindprod.com.invalid> - 2014-02-23 23:16 -0800
Re: comparison of two string Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-02-24 10:46 +0000
Re: comparison of two string Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-02-24 07:59 -0500
Re: comparison of two string Arne Vajhøj <arne@vajhoej.dk> - 2014-02-24 19:24 -0500
csiph-web