Answer to Question #250847 in Java | JSP | JSF for Hilok

Question #250847
Enter 2 words to write to the file from the keyboard. Delete the letters that occur in the second word from the first word. Display the result.
1
Expert's answer
2021-10-13T10:43:55-0400
import java.util.Scanner;
public class Main {
 public static void main(String[] args) {
  Scanner s = new Scanner(System.in);
  String s1 = s.next();
  String s2 = s.next();
  for (int i = s1.length()-1; i >= 0; i = i + 1) {
   if (s2.contains(s1.charAt(i))) {
    s1.deleteCharAt(i);
   }
  }
  System.out.println(s1);
 }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS