Professor Kit Romano's Web Site

 



Site Index

About Me

Welcome
Definition of Program
Variable Types
Understanding Memory
Declaring Variables
Simple Commands
Concatenation and Strings
Sleep-Threads-Try Catch
Campus Scenes
Pictures
Java simplified
Application Shell Styles
Reading Data From File
Overview of Applets
Excellent Graphics Applet
Online Reference
Nested if statements
Arrays
Sorting Arrays
Using Strings
Functions
Top 20 Replies 
First program 211
Important Class Example
JAVA in SDK Environment
Understanding OOP
OOP simple example
Recursion example
Example of Inheritance
     and use of JTextArea



*** Web Related **********
Build Student Web Page ?
What is FTP
Download WS ftp95
Download Java Plug In
Applets from jbuilder to sdk
Practice Problems

 

Programming Examples

 

 

                                                

 

Variable Types

Since Variables stand for items that the program is manipulating

or playing with,  such as:

                        whole numbers       (small  normal   large)

                        fractional numbers        (small   large)

                        single characters

                        groups of characters as a unit

                         true / false conditions

 it is only logical to assume that JAVA gives the programmer  the

 capability to declare and use Variables that can hold each of the

above data types.  Remember that values ( or data ) being put into

Variables is the heart or basis of programming. 


Variables MUST be declared before they can be used in a program.

Common Variable types are as follows:

   short                     ... small integers

   int                          ... normal integers

   long                       ... big integers

   float                       ... small fractional numbers

   double                   ... big fractional numbers 

   char                       ... single character values   e.g.,     M    or   F

   string                     ... groups of characters viewed as a unit

   Boolean                 ... logical  TRUE  or  FALSE  values 

 

In object oriented and more sophisticated programs today, the

programmer can declare his or her own data type ( later )

 

Specifics concerning Java Data TYpes
NUMERIC (all numbers are signed)

short integer (16 bit number) --> i.e. 32,768
int integer (32 bit number) --> i.e. 2 billion or 2 x 109
long integer (64 bit number) --> i.e. 9 x 1018
float real (32 bit decimal) --> i.e. 1.4 x 10-45 to 3.4 x 1038
double real (64 bit decimal) --> i.e. 4.9 x 10-324 to 1.7 x 10308
 

CHARACTER / STRING


char a unicode (2-byte) char
the String class handles multi-character strings (strings are unicode, as well). Strings are said to be immutable: updates to a String cause the new string to be created in memory (and pointed to by the String class). However the old string is not actually "updated", rather, its reference is lost (and it becomes available for garbage collection).

 

BOOLEAN

boolean (with values true, false)

 

DATE

the Date class measures the milliseconds since Jan 1, 1970 and provides supporting functions to interpret and manipulate date/times

 

ARRAYS

arrays hold multiple instances of a data type or object