Reply from kachabi on May 12 at 3:22 AM 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
| | | ---------------Original Message--------------- From: karthikrajun Sent: Thursday, May 10, 2012 10:37 PM Subject: How to Compare Single Character in 2 Arrays in Java Hi, here is my question, i can easily compare them in c++. in c++ we can directly compare the characters between 2 arrays as a[]="karthik"; b[]="raju"; c,d=length of a[] and b[] for(i=0;i<=c;i++){ for(j=0;j<=d;j++){ if(a==a[j]){ a==4; a[j]==5: }}} //so this code will compare the common characters in two arrays and replace with //some other digit cout<<a<<a[j]; when I'm trying this code in java I'm getting so many issues, will some one Please solve this and send the complete code Thanks karthik | | Reply to this email to post your response. __.____._ | _.____.__ |
No comments:
Post a Comment