Professional Documents
Culture Documents
Introduction To Java Introduction To Java: Dr. Anjali Assistant Professor Dr. Anjali Assistant Professor
Introduction To Java Introduction To Java: Dr. Anjali Assistant Professor Dr. Anjali Assistant Professor
Lecture 1:
Introduction to Java
Dr. Anjali
Assistant Professor
Why Java?
2
The benefits of learning to
code with Java
• Java is one of the simplest programming languages to learn and typically
can be mastered in a shorter period of time than other languages.
• There are countless online resources to learn Java, free and paid.
• Everything from application servers to enterprise applications can be built
with Java, making it a high-demand skill in the world of programming and
software development.
• Employment of software developers is projected to grow by 22 percent
between 2020 and 2030, according to the US Bureau of Labor Statistics
[1].
• Java’s popularity continues to grow among leading brands.
Real-world Examples
• Airbnb: For the backend/server-side development of its website and Android app
• Pinterest: For application and data processing, along with other languages
• Uber: To develop and maintain the entirety of its software that processes ride data
• Spotify: For the backend of this music streaming platform
• Slack: For its backend, including the development of Slack SDK for Java
• Amazon: For software development, including Amazon Web Services (AWS)
• Google: For its Google Web Toolkit, Android apps, and Gmail
• Microsoft: To help develop its web browser Edge and its Visual Studio Code
• eBay: To run the backend of its website
• Meta: For backend programming and Android app development for its social media
platforms, such as Facebook and Instagram
• Netflix: For running the backend of this movie streaming website
Why To choose Memory safe
languages?
• https://www.chromium.org/Home/chromium-
security/memory-safety/
• https://msrc.microsoft.com/blog/2019/07/why-rust-for-safe-
systems-programming/
• https://content.techgig.com/technology/the-us-security-
agency-alerts-programmers-for-using-c-and-
c/articleshow/95506366.cms
Ranking
Characteristics of Java
• Java Is Simple Java is partially modeled on C++, but greatly
simplified and improved. Some people refer
• Java Is Object-Oriented to Java as "C++--" because it is like C++ but
• Java Is Distributed with more functionality and fewer negative
aspects.
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-
Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic 7
Characteristics of Java
• Java Is Simple
Java is inherently object-oriented.
• Java Is Object-Oriented Although many object-oriented languages
• Java Is Distributed began strictly as procedural languages,
Java was designed from the start to be
• Java Is Interpreted object-oriented. Object-oriented
• Java Is Robust programming (OOP) is a popular
programming approach that is replacing
• Java Is Secure traditional procedural programming
• Java Is Architecture- techniques.
Neutral
One of the central issues in software
• Java Is Portable development is how to reuse code.
• Java's Performance Object-oriented programming provides
great flexibility, modularity, clarity, and
• Java Is Multithreaded reusability through encapsulation,
• Java Is Dynamic 8 inheritance, and polymorphism.
Characteristics of Java
• Java Is Simple Distributed computing involves several
computers working together on a network.
• Java Is Object-Oriented Java is designed to make distributed
• Java Is Distributed computing easy. Since networking
capability is inherently integrated into
• Java Is Interpreted
Java, writing network programs is like
• Java Is Robust sending and receiving data to and from a
• Java Is Secure file.
• Java Is Architecture-
Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic 9
Characteristics of Java
• Java Is Simple You need an interpreter to run Java
programs. The programs are compiled
• Java Is Object-Oriented into the Java Virtual Machine code called
• Java Is Distributed bytecode. The bytecode is machine-
independent and can run on any machine
• Java Is Interpreted
that has a Java interpreter, which is part of
• Java Is Robust the Java Virtual Machine (JVM).
• Java Is Secure
• Java Is Architecture-
Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple Java compilers can detect many problems
that would first show up at execution time
• Java Is Object-Oriented in other languages.
• Java Is Distributed
Java has eliminated certain types of error-
• Java Is Interpreted
prone programming constructs found in
• Java Is Robust other languages.
• Java Is Secure
Java has a runtime exception-handling
• Java Is Architecture- feature to provide programming support
Neutral for robustness.
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic 11
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
Java implements several security
• Java Is Secure
mechanisms to protect your system
• Java Is Architecture- against harm caused by stray programs.
Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic 12
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture- Write once, run anywhere
Neutral
With a Java Virtual Machine (JVM),
• Java Is Portable you can write one program that will
• Java's Performance run on any platform.
• Java Is Multithreaded
• Java Is Dynamic 13
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-
Neutral
• Java Is Portable Because Java is architecture neutral,
Java programs are portable. They can
• Java's Performance be run on any platform without being
• Java Is Multithreaded recompiled.
• Java Is Dynamic 14
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-
Neutral
• Java Is Portable
Multithread programming is smoothly
• Java's Performance integrated in Java, whereas in other
• Java Is Multithreaded languages you have to call procedures
specific to the operating system to enable
• Java Is Dynamic multithreading.
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-
Neutral Java was designed to adapt to an evolving
environment. New code can be loaded on the
• Java Is Portable fly without recompilation. There is no need for
• Java's Performance developers to create, and for users to install,
major new software versions. New features
• Java Is Multithreaded can be incorporated transparently as needed.
• Java Is Dynamic 16
Compiling Source Code in C
Program Program
Source Machine
Programming Code Compilation Code Execution
Running
Process
17
Compiling/Interpreting Source Code in Java
Program Program
Programming Source Compilation Machine
Code Code Execution
Running
Process
Execution
Programming in interpreted language on example Java
Program Java
Java Source Byte
Programming Code Compilation Code Interpretation Java
Virtual
Machine
18
Creating, Compiling, and Running
Programs
19
Anatomy of your first program
Anatomy of a Java Program
• Class name
• Main method
• Statements
• Statement terminator
• Reserved words
• Comments
• Blocks
21
Trace a Program Execution
22
Trace a Program Execution
Execute statement
23
Trace a Program Execution
24
Appropriate Comments
• Include a summary at the beginning of the program to
explain what the program does, its key features, its
supporting data structures, and any unique
techniques it uses.
• In addition to line comments (beginning with //) and
block comments (beginning with /*), Java supports
comments of a special type, referred to as javadoc
comment (begin with /** and end with */). They can
be extracted into an HTML file using the JDK’s javadoc
command. Use javadoc comments (/** ... */) for
commenting on an entire class or an entire method.
25
Programming Errors
• Syntax Errors
– Detected by the compiler
• Runtime Errors
– Causes the program to abort
• Logic Errors
– Produces incorrect result
26
Errors-Examples
public class ShowErrors1 {
public static main(String[] args) {
System.out.println("Welcome to Java);
}
}