Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //read 2 strings from keyboard says s1 and s2. Report positions and character values where the strings differ.
- import java.util.Scanner;
- public class Positions{
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- System.out.println("Enter two different words");
- String s1;
- String s2;
- s1 = scan.next();
- s2 = scan.next();//where the two inputs come in
- char[] word1= new char[s1.length];
- char[] word2= new char[s2.length];
- for (int j = 0 ; j<word1.length; j++)
- if (word1[j] == word2[j]){
- continue (j=word1.length);}
- else {
- System.out.println(word1[j]);
- System.out.println(word2[j]);
- }
- }
- }
Add Comment
Please, Sign In to add comment