
01-04-2011, 11:42 AM
|
|
|
تاريخ التسجيل: Mar 2011
التخصص: cs
نوع الدراسة: إنتظام
المستوى: الرابع
الجنس: أنثى
المشاركات: 9
|
|
Fix the logical Errors
كود:
//The method below should compare two strings,
//returns “same” if two Strings are identical.
//If they differ, determines the position of
//the first letter at which the two strings differs,
//and returns that position public String compareStrings(String a,String b){
int pos =0;
if (a.equals(b)){
return "same";
}else{
while (b.charAt(pos)!=a.charAt(pos));
{
pos++;
}
return "They differ at position:" + pos;
}}
|