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

What it's about.

=================

We have these two variables :

Two java.awt.TextFields are used to show these.

byteuno is shown in the first TextField, shortuno in the second.

The first two buttons, btn and btn2, are used to increment or decrement byteuno.

If you increment it a couple of times, you'll notice it changes to 127, -128, -127 etc.

This is because a byte is so small, it can only contain a limited range of numbers :
  -128 through +127 .

A short is 2 bytes long, so it can contain a wider range :
  -32768 through +32767 .

An int , 4 bytes :
  -2,147,483,648 through +2,147,483,647 .

A long, 8 bytes :
  -9223372036854775808
  through +9223372036854775807 .

The types mentioned above are meant for numbers without fractions.

For numbers with fractions we can use float and double.

The range of float (4 bytes) :
  1.40239846E-45 through +3.40282347E38 .

( E-45 means : decimal point 45 places to the left

  0.0000000 etc 0000000000000140239846

E38 : decimal point 38 to the right

340282347000000000000000000000000000000.0

)

The range of double (8 bytes) :
  4.94065645841246544E-324
through 1.7976931348623157E308 .

=== IMPORTANT =============

The length in bytes and thus, the ranges, of these types are always the same in Java. On every platform.

========

In a float you can store values like these :
0.00000056644823
566448230000000.0
566.44823

but NOT :
24454.688974456624
0.0000002445468897445662

For these, you need a double.

As a rule, you can store 8 significant ( left-most, leading zeroes excluded ) positions in a float and 17 in a double.

========

These are all fundamental ( 'primitive' ) data types.

SINGLE QUOTES. \n = newline, special character. \\ = backslash .

true and false are values by themselves, they can NOT BE USED AS NUMERICAL values or vice-versa.

false is NOT EQUIVALENT to the value zero.

========

NOTES

========

To ascertain which button was clicked, we ask the ActionEvent for it's source :

If it was the first button, we increment byteuno by one :

put it in the first TextField :

and get out of the actionPerformed method :

Because TextField's setText method wants a String as parameter and byteuno isn't a String, we use a neat little trick :


  byteuno + ""
to obtain a String.

=========

The TextFields are created as showing 10 positions.

.