Java tutorial
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String text = "q"; while (true) { System.out.print("Please type a message (Q/q to quit) and press enter:"); text = br.readLine(); if (text.equalsIgnoreCase("q")) { System.out.println("We have decided to exit the program"); break; } else { System.out.println("We typed: " + text); } } } }