JAVA Programming: MC Wilford Paclar

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

JAVA Programming

Mc Wilford Paclar

Introduction to JAVA
created in 1991 by James Gosling et al. of Sun Microsystems. Initially called Oak Star 7 first project using Java It is the current HOT language Its almost entirely object-oriented

Main deployment Environment


Java Runtime Environment (JRE)
supplied by the Java 2 Software Development Kit(SDK) contains the complete set of class files for all the Java technology packages.

Web browser
Has a Java technology interpreter and runtime environment.

Phases of Java Program

Task Write the program Compile the program Run the program

Tools to use Text editor Java Compiler Java interpreter

Output File with .java extension File with .class extension (bytecode) Program output

A picture is worth

The Interpreter's are sometimes referred to as the Java Virtual Machines

A Simple Java Program


public class Hello { public static void main(String[] args) { System.out.println("Hello World!"); } }

This would be in a text file named Hello.java DEMO of writing and running a program via Jcreator or Eclipse

Java Primitive Data Types


Data type determines the values it may contain.
Type Contains Default Size Range -2147483648 to 2147483647 439E-324 to 1.797693134 8623157E+308

int

Signed integer
IEEE 754 floating point

4 bytes

double
boolean char

0.0
False
\u0000

8 bytes
1 bit 2 bytes

True or false
Unicode character unsigned

N/A
0 to 216-1

Java Primitive Data Types


Type byte short Contains Signed integer Signed integer Default 0 0 Size 1 byte 2 bytes Range -128 to 127 -32768 to 32767 922337203685 4775808 to 922337203685 4775807 1.4E-45 to 3.4028235E +38

long

Signed integer

8 bytes

float

IEEE 754 floating point singleprecision

0.0f

4 bytes

Java Variables
a symbolic name associated with a value that can be changed.
Data_type name [=initial value]; Example: int rate = 80; float salary; salary = 15.80; Declare and initialize variable rate Declare variable salary Initialize variable salary

More Definitions
code or source code: The sequence of instructions in a particular program. output: The messages printed to the computer user by a program. console: The text box or window onto which output is printed.

You might also like