Programming in Java
PROGRAMMING
A set of such instructions is known as a program and the
act of creating a program is known as programming.
A program is a collection of instructions that performs a
specific task when executed by a computer.
Programs are created to solve the problems, to automate
the processes and to reduce repetitive and/or manual
work.
Process is basically a sequence of computations to be
performed using some logic.
complete set of steps is called as an Algorithm
Algorithm
The statements which change the flow or order of execution of
the instructions are called control structures.
There are three types of control structures:
Sequential
Selection
Iteration
Selection control structures are implemented using if-
else blocks.
Iteration Control Structure.
While iteration is unknown
For iteration is known
JAVA
High-level programming languages.
program that we write needs to get converted into binary form
for the computer to understand.
This conversion is made possible using system
software called compilers and interpreters{binary form}.
Java (source code) compiled and converted into byte
code (compiled code) interpreter reads the byte code line by
line, converts it to binary form, also called as machine language
or binary language
This process requires some support and an environment for the
execution to happen. JDK (Java Development Kit) helps in this
for execution of a Java program. It provides library support and
Java Runtime Environment (JRE), the environment for
developing and executing Java based applications and
programs.
IDE (Integrated Development Environment) to code Java
programs.
An IDE is a software application that is required to write,
execute and test programs
Every statement in Java must be present inside
a method. A method is a block of code that performs a
particular task.
Every method in Java must be present inside a class
Java compiler ([Link]) - It is the primary Java
compiler. The compiler accepts Java source code and
produces Java bytecode conforming to the Java Virtual
Machine Specification (JVMS).
Java launcher ([Link]) - It helps in launching a Java
application during execution.
Next, let us discuss about Java Runtime Environment (JRE).
The Java Runtime Environment (JRE) contains Java Virtual
Machine(JVM) and the Java standard library (Java Class Library).
Java Virtual Machine (JVM) - It is the virtual machine that
enables the computer to run Java programs.
Java standard library (Java Class Library) - It is a set
of dynamically loadable libraries that Java applications can
call at run time. Java Platform is not dependent on a
specific operating system and hence applications cannot
rely on any of the platform-native libraries. So, the Java
Platform provides a set of standard class libraries
containing functions common to modern operating
systems.
platform independent
A program written using Java on Windows will execute without
any recompilation on any other platform.
keywords which are reserved words having a predefined
meaning
VARIABLEData is stored in variables. A variable is a named
memory location which holds some value. The value stored in a
variable can vary during the execution of the program.
identifier is the name given to a variable, method or class to
uniquely identify it.
Data type defines the type of data that can be stored in the
variable and the memory required by it.
Non-primitive data types include classes, arrays, interfaces etc.
These can be predefined in Java library or user-defined in the
programs. These will be covered in detail later in the course.
E.g. - String is a predefined class in Java library which is used to
store a sequence of characters:
String customerName = "Jamie";
//This is a single line comment
/*This is a
multi-line comment*/
Operators are the symbols used to perform specific operations.
There are various operators that can be used for different
purposes.
The operators are categorized as:
Unary
Arithmetic
Relational
Logical
Ternary
Assignment
Bitwise