Comparing strings ignoring whitespaces

Report a typo

Write a program that reads two lines and compares them without whitespaces. The program should print true if both lines are equal, otherwise – false.

Sample Input 1:

  string
str ing 

Sample Output 1:

true

Sample Input 2:

string
my string

Sample Output 2:

false
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// start coding here
}
}
___

Create a free account to access the full topic