Introduction to Java Programming
Lecture 3
Department of Computer Science and Engineering, ITER
Siksha ’O’ Anusandhan (Deemed to be University), Bhubaneswar, Odisha, India.
1 / 13
Contents
1 Introduction
2 Features of Java Programming
3 The Java Environment
4 A Simple Java Program
2 / 13
Introduction
Java is a general-purpose, object-oriented programming
language designed for the development of software for consumer
electronic devices.
Java is a platform neutral language.
Java programming language was developed by Sun Microsystems
in 1991.
The team for the development of Java discovered that the existing
languages had some major drawbacks in terms of reliability and
portability.
The main goal for the developers was to make the language
highly reliable, portable and simple.
3 / 13
Features of Java Programming
Compiled and Interpreted
Independent and Portable
Object-Oriented
Robust and Secure
Distributed
Simple, Small, and Familiar
Multithreaded and Interactive
High Performance
Dynamic and Extensible
Ease of Development
4 / 13
The Java Environment
Figure 1: Java Environment
5 / 13
Java Development Kit (JDK)
Java Development Kit is the core component of Java Environment.
It provides all the tools, executables, and binaries required to
compile, debug, and execute a Java Program.
JDK is a platform-specific software.
JDK is the superset of Java Runtime Environment(JRE).
6 / 13
Java Runtime Environment(JRE)
It provides a platform to execute java programs.
JRE consists of JVM, Java binaries, and other classes to execute
any program successfully.
JRE doesn’t contain any development tool.
Application Programming Interface (API) : This is a collection
of Java classes and methods required for implementing basic
features of Java.
7 / 13
Java Virtual Machine(JVM)
JVM is the heart of Java programming language.
JVM is responsible for converting the byte code to the
machine-specific code.
JVM is called virtual because it provides an interface that does
not depend on the underlying operating system and machine
hardware.
This independence from hardware and the operating system
makes java program write-once-run-anywhere.
8 / 13
A Simple Java Program
p u b l i c c l a s s Welcome
{
p u b l i c s t a t i c v o i d main ( S t r i n g [ ] args )
{
/ / D i s p l a y Welcome t o Java ! on console
System . o u t . p r i n t l n ( ” Welcome t o Java ! ” ) ;
}}
Line 1 defines a class.
Line 2 defines the main method.
Line 3 is a comment.
Line 4 print the message.
9 / 13
Few Things to Note
Every Java program must have at least one class.
By convention, class names start with an uppercase letter.
The main method is the entry point where the program begins
execution.
A method is a construct that contains statements.
This statement displays the string Welcome to Java! on the
console.
A string must be enclosed in double quotation marks.
Every statement in Java ends with a semicolon (;), known as the
statement terminator.
10 / 13
Comment and Block
Comments help programmers to communicate and understand
the program.
They are ignored by the compiler.
Two slashes (//) on a line, called a line comment.
(/* ... */) on one or several lines, called a block comment or
paragraph comment.
A pair of curly braces in a program forms a block that groups the
program’s components.
Each block begins with an opening brace ({) and ends with a
closing brace (}).
11 / 13
Program to Display More Messages
p u b l i c c l a s s Welcomewith3msg
{
p u b l i c s t a t i c v o i d main ( S t r i n g [ ] args )
{
System . o u t . p r i n t l n ( ” Welcome t o ITER ! ” ) ;
System . o u t . p r i n t l n ( ” Welcome t o SOA ! ” ) ;
System . o u t . p r i n t l n ( ” Welcome t o Odisha ! ” ) ;
}
}
12 / 13
References
Y Daniel Liang ‘Introduction to JAVA Programming, Comprehensive Version’,
Pearson, 2014.
13 / 13