public class numerodetel {**strong text**
static void commun(String tel1, String tel2){
for(int i=0;i<tel1.length();i++){
for(int j=0;j<tel2.length();j++){
if(tel1.charAt(i)==tel2.charAt(j))
System.out.printf(" %c,", tel1.charAt(i));
}
}
}
public static void main(String[] args){
String telUDM = "5143436111", telJean = "4501897654";
commun(telUDM, telJean);
}
}
The code works and I am able to find the common numbers between the two phone numbers. Is there an easy way, though, to make it so that once a common number is detected between the two, it doesn't reappear again? In this case it would be 5, 1, 4, 6.