14 Replies Latest reply: Jun 12, 2008 12:19 PM by 807591 RSS

    Compare individual char of 2 string

    807591
      Hi

      I need to compare the each individual char of 2 string.

      String a = "Ae12";
      String b = "aE12";

      // I tried the followings:
      // a
      String c = a.substring(0,0);
      String d = a.substring(1,1);
      String e = a.substring(2,2);
      String f = a.substring(3,3);
      // b
      String c1 = b.substring(0,0);
      String d1 = b.substring(1,1);
      String e1 = b.substring(2,2);
      String f1 = b.substring(3,3);

      if(c.equalsIgnoreCase(c1)&&d.equalsIgnoreCase(d1)&&e.equalsIgnoreCase(e1)&&f.equalsIgnoreCase(f1)) // Cannot be compared

      // and I tried the followings:
      // a
      char c = a.charAt(0);
      char d = a.charAt(1);
      char e = a.charAt(2);
      char f = a.charAt(3);
      // b
      char c1 = b.charAt(0);
      char d1 = b.charAt(1);
      char e1 = b.charAt(2);
      char f1 = b.charAt(3);

      if(c==c1&&d==d1&&e==e1&&f==f1) // cannot be compared.

      Both cases cannot be compared. How can I fix it?

      Because I want to compare those 2 strings without case sensitive and numbers.

      Thanks