Day 1:-
Java Introduction
an
Introduction of Java
th
Java is one of the most popular programming
an
languages in the world, it is an objectoriented
programming language.
m
The Java platform provides a complete environment
bo
for application development on desktops and
Ro
servers and deployment in embedded
environments.
Java was developed by James Gosling in 1995, at
Sun Microsystems which was later acquired by
Oracle in 2010
It was originally called OAK after an OAK tree that
stood outside Gosling’s Office, later it was
renamed “Green” and was finally renamed to
“Java” inspired by Java Coffee, that’s why its
logo looks like a cup of coffee.
Java Edition
We have 3 editions of Java for building a different kinds
of applications
1. Java Standard Edition (JSE)
Java Standard Edition (JSE) is the core platform for
an
developing and running Java applications on desktops
and servers. It provides essential libraries, tools, and
th
runtime environments necessary for Java programs to
function independently of specific hardware or
an
operating systems.
m
2. Java Enterprise Edition (JEE)
bo
The Java EE platform provides an API and runtime
Ro
environment for developing and running large-scale,
multi-tiered, scalable, reliable, and secure network
applications.
3.Java Micro Edition (JME)
It is a subset of Java SE, designed used for
microdevices and embedded development like mobile
phones, sensors, micro-controller, TV set-top boxes
etc.
Note:- JSE is the basic foundation of the remaining 2
other editions.
The latest version of Java is Java 21 which was
released on 19- September 2023.
Java has close to 17 million developers
worldwide, currently, about 3 billion mobile
phones run java, Now a day java is everywhere,
an
which means more opportunities for us to get
hired as a professional programmers.
th
Features of Java
an
Simple:- Java is easy to learn and its syntax is quite
m
simple, clean and easy to understand.
bo
Object-Oriented:- Java is object-oriented, it
Ro
supports all the OOPS characteristics. This makes
java applications easy to develop and maintain,
compared to structured programming language.
Platform Independent:- Java source code is
compiled and converted into bytecode. this
bytecode can run on multiple platforms i.e. Write
Once and Run Anywhere(WORA), we can compile
the java code in one Operating System and
execute it on another Operating System.
Robust:- Robust means strong. Java is having a very
good memory management system in the form of a
heap memory management system, it is a dynamic
memory management system, it allocates and
deallocates memory for the objects at runtime.
Multithreaded:- Java supports multithreading to
enhance performance. by using this we can
execute multiple functionalities simultaneously.
an
JDK or Java SDK
th
Java Standard Edition comes in the form of
an
Specification, and the implementation of this
specification is the JDK software, also known as
m
Java SDK (Java Standard Development Kit).
bo
This JDK software is used for developing and
Ro
executing Java applications.
JDK = (JRE + Development tools like java compiler,
debugger, etc.)
JRE = (JVM + Predefined Library classes)
Basic Steps To Develop a Java
Program:
an
th
an
m
bo
Ro
JDK(Java Development Kit)
JDK is a software development kit used by
programmers to develop Java applications. It
includes tools such as compilers, debuggers, and
libraries needed to write, compile, and run Java
programs.
JRE(Java Runtime Environment)
JRE is the environment required to run Java
applications. It includes the Java Virtual Machine
(JVM) and libraries necessary to execute Java
bytecode.
JVM(Java Virtual Machine)
JVM is a software component that runs Java
bytecode, allowing Java programs to be executed on
different platforms without modification. It serves
an
as an intermediary between Java code and the
th
underlying hardware and operating system.
Basics of a Java Application
an
The smallest building block in java application is
m
function/method.
bo
A method is a block of code that performs a well-
defined task. example: a method for adding 2
Ro
numbers, a method for validating user input, a
method for calculating interest, etc.
the basic syntax of a method in Java application is:
returnType methodName(){
--instructions--
}
Some method returns some value, whereas some
method does not return any value. the method
which does not return any value we apply void as a
return type. void is a reserved keyword in java, the
method name should be proper and descriptive.
Example:
Example
void calculateInterest(){
}
We can pass some parameters to this method also, we
an
use parameters to pass the value to our method. for
example, amount, rate of interest, duration, etc.
th
and inside the pair of parenthesis { }, we write the
an
actual implementation java cod
m
Every java program should have at least one method.
and that method is called the main method.
bo
Ro
The main method is an entry point of our java
application
Whenever we execute a java program, the main
function gets called and the code inside this main
method gets executed.
These methods don't exist as their own, they always
belong to a class.
A class is like a container, of one or more methods.
We use the class to organize our code in the java
application.
Every java program should have at least one class,
which contains the main method.
Our first java program:
Main.java
Here class is a keyword, by which we define a class in
an
java. we should give a proper descriptive name to the
class.
th
In Java, all the classes and methods should have an
an
access modifier.
An access modifier is a special keyword that
m
determines if other classes and methods in this
program can access these classes and methods.
bo
We have various access modifiers are there like public,
Ro
private, and so on. most of the time we use public
access modifier.
So, the basic structure of a java program contains a
class and inside the class, we have a main method.
To name our classes we use
PascalNamingConvention(first letter of every word
in uppercase
To name our methods we use camelNamingConvenion.
Note: All java files should have a .java extension. and
every statement in the java application should be
terminated with a semicolon ;
an
The static is a keyword, we will talk about this
th
keyword later, for now, just remember the main
an
method in our program should always be static. and
the return type of this method is void, which means
m
this method is not going to return any value.
bo
In the main method, we have one parameter, we can
use this parameter to pass values to our program.
Ro
System.out.println("Hello World");
Here System is a predefined java class, which
belongs to java.lang package. inside this class, we
have various members, out is a member (field) who
belongs to this System class.
the type of this out field is the PrintStream class. this
PrintStream is another predefined class in java. the
println method belongs to this PrintStream class.
So here we are calling or executing the println method
inside our main method
Inside the parenthesis of this println method, we can
pass any value, which we want to print on the
terminal or console.
Here “Hello World” is textual data, in java whenever
we deal with textual data we should always surround
them with double-quotes. which is known as a string.
In java, a string is a sequence of characters
You Problem:
Write a java application that will print Your Name
an
and Address in the following pattern:
th
an
m
bo
Ro