Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27583
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: comparison of two string |
| Date | Mon, 24 Feb 2014 07:59:41 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 30 |
| 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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Mon, 24 Feb 2014 12:59:39 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="27478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182YJY4gDXjtuL1omuWGwQY" |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
| In-Reply-To | <slrnlgm8od.g8j.avl@login.logic.tuwien.ac.at> |
| Cancel-Lock | sha1:YL89PrVBGToKwIIC/xbRKoEjhXg= |
| Xref | csiph.com comp.lang.java.programmer:27583 |
Show key headers only | View raw
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