String comparison in Java

Posted by Kliver Max on Stack Overflow See other posts from Stack Overflow or by Kliver Max
Published on 2012-10-23T04:50:18Z Indexed on 2012/10/23 5:02 UTC
Read the original article Hit count: 131

Filed under:

I want to compare two strings using Java. First sting name i get from .mif file using GDAL in cp1251 encoding. Second kadname i get from jsp. To compare i do this:

if (attrValue instanceof String)
{
    String string3 = 
        new String((attrValue.toString()).getBytes("ISO-8859-1"), "cp1251");
    dbFeature.setAttribute(name, string3);
    System.out.println("Name=" + name);
    System.out.println("kadname=" + kadname);
    if (name.equalsIgnoreCase(kadname))
    {
        kadnum = string3;
        System.out.println("string3" + string3);
    }
}

And in console i get this:

Name = kadnumm
kadname = kadnumm

Whats wrong with this?

© Stack Overflow or respective owner

Related posts about java