Tutorial by Examples

Using BufferedReader: System.out.println("Please type your name and press Enter."); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); try { String name = reader.readLine(); System.out.println("Hello, " + name + "!"); } catch(I...
For basic prototypes or basic command-line behavior, the following loop comes in handy. public class ExampleCli { private static final String CLI_LINE = "example-cli>"; //console like string private static final String CMD_QUIT = "quit"; //string for exit...
The method PrintWriter.format (called through System.out.format) can be used to print aligned strings in console. The method receives a String with the format information and a series of objects to format: String rowsStrings[] = new String[] {"1", &q...

Page 1 of 1