How can I check to see if a String contains a whitespace character, an empty space or \" \". If possible, please provide a Java example.
For example: String
public static void main(String[] args) {
System.out.println("test word".contains(" "));
}
package com.test;
public class Test {
public static void main(String[] args) {
String str = "TestCode ";
if (str.indexOf(" ") > -1) {
System.out.println("Yes");
} else {
System.out.println("Noo");
}
}
}