Java : check string match four “=” or more [duplicate]

You can simply see if it contains ==== with yourString.contains("====") – example:

class Main {
    public static void main(String[] args) {
        String input = new Scanner(System.in).nextLine();
        if(input.contains("===="))
            System.out.println("Contains ====");
        else
            System.out.println("Doesn't contain ====");
    }
}

Leave a Comment