Reply from karthikrajun on May 12 at 11:32 AM Hi, thank you for your response. Here is the description of my code the main purpose of this code is, 1) This program will read two names from keyboard into an array. 2) Now it will compare each and every character between two arrays, and repalces with an empty space. 3) At final it will count the remaining characters in both arrays, I completed in c++ but in java/jsp I am not getting issues char a[20],b[20]; int size,size1,i,j; cout<<"enter first,second name"; cin.getline(a,20); cin.getline(b,20); size=strlen(a); size1=strlen(b); for(i=0;i<size;i++) { for(j=0;j<size1;j++) { if(a==b[j]){ a=' '; b[j]=' '; }}} output enter two names karthik raju here common characters are "a" and "r" so it will replaces with empty space o/p kthik ju, there fore count is 7. Can you Please send the java/jsp code with these requirements. Regards, Karthik
| | | ---------------Original Message--------------- From: somesh Sent: Friday, May 11, 2012 12:30 AM Subject: How to Compare Single Character in 2 Arrays in Java hi, see you r using "==" which checks equality of reference variables in java, so use equal() method of java.lang.object which makes value check so use it as a.equals(a[j]) this will work .it is java be care full while using "==" and equals(). | | Reply to this email to post your response. __.____._ | _.____.__ |
No comments:
Post a Comment