Reply from anilkumarmallavarapu on May 12 at 11:15 AM public class Chek { public static void main(String args[]) { String a[]={"A","B","C"}; String[] b={"B","B","D"}; for(int i=0;i<a.length;i++) { for( int j=0;j<b.length;j++) { if(a.equals(b[j])) { System.out.println("Matched Charecter in Array a["+i+"]"+a); System.out.println("Matched Charecter in Array b["+j+"]"+b[j]); } } } } } use this code to compare your code solve the problem
| | | ---------------Original Message--------------- From: katchapakesan thamotharan Sent: Saturday, May 12, 2012 3:24 AM Subject: How to Compare Single Character in 2 Arrays in Java HI , I have given the code to compare 2 chars are equal import java.util.Arrays; public class CompareCharArraysExample { public static void main(String[] args) { //create character arrays char[] charArray1 = new char[]{'d','h','r','f'}; char[] charArray2 = new char[]{'d','h','r','f'}; boolean blnResult = Arrays.equals(charArray1,charArray2); System.out.println("Are two char arrays equal ? : " + blnResult); // Note : put the logic as under: i) if blnResult gives ' true' value, do some logic. ii) if blnResult gives ' false' value, do some other logic. //pls proceed according to ur requirement } } Regards, Katchapakesan.T | | Reply to this email to post your response. __.____._ | _.____.__ |
No comments:
Post a Comment