Guest User

Untitled

a guest
Dec 11th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. //read 2 strings from keyboard says s1 and s2. Report positions and character values where the strings differ.
  2. import java.util.Scanner;
  3.  
  4. public class Positions{
  5. public static void main(String[] args){
  6. Scanner scan = new Scanner(System.in);
  7. System.out.println("Enter two different words");
  8. String s1;
  9. String s2;
  10. s1 = scan.next();
  11. s2 = scan.next();//where the two inputs come in
  12. char[] word1= new char[s1.length];
  13. char[] word2= new char[s2.length];
  14.  
  15.  
  16. for (int j = 0 ; j<word1.length; j++)
  17. if (word1[j] == word2[j]){
  18. continue (j=word1.length);}
  19. else {
  20. System.out.println(word1[j]);
  21. System.out.println(word2[j]);
  22. }
  23.  
  24. }
  25. }
Add Comment
Please, Sign In to add comment