Java Development Kit (JDK).
• JAVA DEVELOPMENT KIT (JDK) is s software development environment used for
developing java applications and applets.
JDK includes – Java Runtime Environment.
Java Virtual Machine.
Compiler.
Debugger.
JDK
JRE
JVM
JRE - Java Runtime Environment.
JVM - Java Virtual Machine
Java Programming Environment.
App.java App.class JVM Program
Compiler ByteCode
(Javac)
I. Source code is written in plain text with “.java” extension.
II. Using Javac Command App.java is compiled in to App.class.
III. App.class file Contain the ByteCode of the App.java.
IV. ByteCode is the machine language of JVM.
V. Then the java launcher tool runs your application with an instance of the JVM.
JRE - Java Runtime Environment.
• Besides the Java Virtual Machine, JRE is composed of a variety of other supporting
software tools and features to get the most out of your Java applications.
Definition
• The Java Runtime Environment is a software layer that runs on top of a computer’s
operating system software and provides the class libraries and other resources that a
specific Java program needs to run.
The Java Platform.
• The Java platform differs from most other platforms in that it's a software only
platform that runs on top of other hardware-based platforms.
The Java platform has two components:
I. The Java Virtual Machine
II. The Java Application Programming Interface (API)
I. The Java Virtual Machine.
• Collection of Software components that enables a computer to run a java
program.
II. Java Application Programing Interface. (API)
• The API is a large collection of ready-made software components that
provide many useful capabilities.
Ex: - Java Swing, AWT.
Scanner.
App.java
API
JVM
Hardware Based Platform
Java Editions
J2SE – Java 2 Standard Edition. (For Client-Side Standalone Apps.)
J2ME - Java 2 Micro Edition. (For Mobile Devices Apps.)
J2EE - Java 2 Enterprise Edition. (For Server-Side Apps.)
Top Level Elements Appears In A Java Source File.(In order)
I. Package Name.
II. Import Statements.
III. Class definitions.
Data Types.
Byte - 8 bits.
Short - 16 bits.
Int - 32 bits.
Long - 64 bits.
Char - 16 bits.
Float - 32 bits.
Double - 64 bits.
Operators.
\t - Tab space
\b - Back space.
\n - New line.
\’ - Single Quotation.
\” - Double Quotations.
\\ - Backslash.
Garbage Collector.
When Java programs run on the JVM, objects are created on the heap, which is a portion of
memory dedicated to the program. Eventually, some objects will no longer be needed. The
garbage collector finds these unused objects and deletes them to free up memory.
Control Statements.
1. Sequential structure. - Default
2. Selection structure. - if – else, Switch case
3. Repetition structure. - while, do-while, for
Array
An array is a container object that holds a fixed number of values of a single type.
1st method
int [] Marks= { 60, 45, 65,94, 78,72,62,78,88};
2nd method
int Marks [] = new int [10] ;
// declares an array of integers and allocates memory for 10 integers
Marks [0] = 67;
// initialize first element
2D Array
1st method
int [][] Marks={ { 60, 45, 65,94}, {78,72,62,78,88} };
2nd method
int Marks [][] = new int [10][10] ;
// declares an array of integers and allocates memory for 10*10 integers
Marks [0][0] = 67;
// initialize first element
Identifiers.
An identifier is a word used by programmer to name a variable, method, class or label.
Must begin with – A letter, A dollar sign ‘$’, underscore ‘_’
Should not contain any java keywords.
Type conversion and Casting
Casting let you to convert primitive values from one type to other.
2 types - implicit
-explicit
Implicit cast happen when you’re doing a widening conversion.
Ex:
int a = 100;
long b =a;
Explicit cast happen when you’re doing a narrowing conversion.
Ex:
double a = 100.04;
int b =(int)a;
Access Modifiers