import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        for (var i = 1; i <= 10; i++) {
            System.out.println("Intento: " + i);
            if (getText() == null) continue;
            System.out.println(getText().trim());
        }
    }

    public static String getText() {
        var random = Math.random();
        System.out.println("random: " + random);
        return random > 0.5 ? null : "Hola";
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: