Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com

In a simplistic, stand-alone ( non-browser, non-visual ) application we can use java.util.Scanner to get console input in different manners.

Stand-alone applications always start in a main method, that should be written exactly as given.

Tell the user what's to be done.

Get the line of text using one of Scanner's methods, 'nextLine'.

Change to uppercase and show it.

Then we process another series of words, starting off by getting the first one.

As long as the current word, irrespective of case, is not equal to 'bye', where NOT is indicated by the exclamation mark,...

process it,...

and get the next word from the input.

By calling nextInt, Scanner will try to parse a number, an int, from the console input.

Provided the input was correct, the number is multiplied by two and shown.

If a number can't be distilled, an exception is thrown, indicating erroneous input.

How to handle exceptions properly can be found in the Exceptions lesson.

========

NOTES

========

Running a standalone application in Eclipse can be done by choosing Run, Run As, Java Application.

In a console window, you can do something resembling this :

========

Scanner is available since Java 5 and contains many more methods to satisy text parsing needs.

It can also be used to parse text files instead of console input.

========

System.in , System.out , default input, output : console.

========

Curly brackets.

.