Вы находитесь на странице: 1из 29

Passion for training. Passion for technology.

Prepared by:

Passion for training. Passion for technology.

Mr. Leo Mark Corayag

zhayk_denki

JAVA History
Java
was

Passion for training. Passion for technology.

created in 1991 by James Gosling et al. of Sun Microsystems. Initially called Oak, in honor of the tree outside Gosling's window, its name was changed to Java because there was already a language called Oak.
-takumo-

JAVA History
Java
The

Passion for training. Passion for technology.

original motivation for Java the need for platform independent language that could be embedded in various consumer electronic products like toasters and refrigerators.

JAVA History
One

of the first projects developed using Java


a personal hand-held remote control named Star 7.

Passion for training. Passion for technology.

At

about the same time, the World Wide Web and the Internet were gaining popularity. Gosling et. al. realized that Java could be used for Internet programming.

What is JAVA?
Is

Passion for training. Passion for technology.

an object-oriented language that is used for general-purpose business programs and interactive Wide Web based Internet programs. It is architecturally neutral, which means JAVA can run in different platforms.

What is JAVA?
Java has its own interpreter or compiler. It translates for the host machine. The compiler translates the written syntax into bytecode which is read by the JAVA VIRTUAL MACHINE (JVM). A Java Virtual Machine (JVM) is a virtual machine that interprets and executes Java bytecode.

Passion for training. Passion for technology.

Starting a Program

Consider the following simple program. This is written on seven lines, and its only task is to print First Java Program on the screen. public class First { public static void main (String [] args) { System.out.println(First Java program); } }

Passion for training. Passion for technology.

More Info about JAVA

Passion for training. Passion for technology.

The string First Java program appears within the parentheses () because string is an argument to a method, and arguments to methods always appear within parentheses. Println is the method. Arguments consists of information that a method requires to perform its task.

Dissection of Codes
System.out.println(First Java Program); System - is a class, defines attributes of a collection system objects.
Passion for training. Passion for technology.

Out - is an object of a class. It represents the screen. println - is a method. Command to display.

Dissection of Codes
public class First public - is an access identifier, which defines how the class is accessed. Just follow it with class First which is the name of the class.

Passion for training. Passion for technology.

Dissection of Codes method header


public static void main(String[]args) static - it means unchanging. The main()method cannot be change. void means empty. It does not indicate that the main() method is empty, but rather, the main method does not return any value when it is called.

Passion for training. Passion for technology.

Create your first program in JAVA


Create a program that displays Hello, world! as its output. Public class Hello { public static void main (String [] args) { System.out.println(Hello, world!); } }

Passion for training. Passion for technology.

Modifying a Program
To edit a program you must open an existing program. Public class Hello { public static void main (String [] args) { System.out.println(My new and improved); System.out.println(Java program); } }

Passion for training. Passion for technology.

Using Data Types


Variables and Constants Data is constant when it cannot be changed. Data is variable when it might change.

Passion for training. Passion for technology.

-takumo-

Using Data Types


JAVA has eight Primitive Data types -primitive- means simple and uncomplicated

Passion for training. Passion for technology.

Boolean Byte Char Double

Float Int Long Short

For Integer Type of variable


Byte Short Int Long

Passion for training. Passion for technology.

For Integer Type of variable


Type Byte short
Passion for training. Passion for technology.

Maximum Value -128 -32,786 -2,147,483,648

Minimum Value 128 32,786 2,147,483,648

Byte 1 2 4 8

Int Long

9,223,372,036,8 9,223,372,036,85 54,775,808 4,775,808

Using Int
Create a program that will use int as a data type of a variable: public class DemoVariables { public static void main(String [] args) { int oneInt = 315; System.out.print(The int is ); System.out.println(oneInt); } }

Passion for training. Passion for technology.

Declaring two or more variables in the program


Use this variables and display each output. Make Number as a class. Short oneShort = 23; Long oneLong = 123456789876543L;

Passion for training. Passion for technology.

Shortcut of output
In the previous program, we used two print method like this: System.out.print(The int is ); System.out.println(oneInt);
Passion for training. Passion for technology.

We can use this shortcut method to make it easier. System.out.println(The int is + oneInt);

Modifying to variables
Edit the program of class Number so that the output will be in the shortcut method. System.out.println(The short is + oneShort); System.out.println(The long is + oneLong);

Passion for training. Passion for technology.

Arithmetic Statements
Addition

Passion for training. Passion for technology.

+ Subtraction Multiplication * Division / Modulus %

Using Arithmetic Statements


Create a program that will calculate the sum of the given variables. Using Int data type.
Passion for training. Passion for technology.

Value1 = 43 Value2= 10

Using Arithmetic Statements


Create a program that will calculate the sum and difference of the given variables. Using Int data type.
Passion for training. Passion for technology.

Value1 = 43 Value2= 10

Using Arithmetic Statements


Create a program that will calculate the product of the given variables. Using Int data type.
Passion for training. Passion for technology.

Value1 = 43 Value2= 10

Using Arithmetic Statements


Create a program that will calculate the quotient and Product of the given variables. Using Int data type.
Passion for training. Passion for technology.

Value1 = 43 Value2= 10

Using Arithmetic Statements


Create a program that will calculate the Remainder of the given variables. Using Int data type.
Passion for training. Passion for technology.

Value1 = 43 Value2= 10

Using Arithmetic Statements


Create a program that will calculate all the Arithmetic operation of the given variables. Using Int data type.
Passion for training. Passion for technology.

Value1 = 43 Value2= 10

Passion for training. Passion for technology.

Вам также может понравиться