codice:
public static void main(String[] args)
    {
        System.out.println("Scrivi un testo di massimo 20 caratteri.");
        String s = SavitchIn.readLine();

        while(!check(s))
        {
            System.out.println("Hai scritto un testo troppo lungo");
            s = SavitchIn.readLine();
        }
        
        System.out.println("Hai inserito " + s.length() + " caratteri.");
    }
    
    private static boolean check(String s)
    {
        return s.length() < 20;
    }
?