Integer Formatting Applet

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.
go to previous page   go to home page   go to next page        

Answer:

  • , comma
  • . dot
  •   space

Of course, a given locale uses only one of these characters for this purpose.

Integer Formatting Applet

Here is an applet that formats an integer using DecimalFormat.format(). Enter an integer (as characters) into the text box and click on the button.

Embedded Java applet removed: modern browsers do not support Java applets. The surrounding source code is retained for historical study.

If you enter characters that can't be converted to an int, an error message will be written. Incorrect character strings include those that contain commas, dots, or spaces. The input must be unformatted. Other incorrect strings include those for integers that are too big (greater in magnitude than about two billion).

QUESTION 4:

How would you prefer to see this number displayed:

12345.6789