Introduction to Java
Introduction to Java
Java is an object-oriented Java programs can run on Java has built-in security
programming language, any device or operating features, automatic
which means it focuses on system that has a Java memory management,
creating objects that Virtual Machine (JVM) and strong type-checking,
contain both data and installed, making it highly making it a reliable and
code. portable. secure language.
History and Versions of Java
1995: Java 1.0 Release 1
Java was first released by Sun
Microsystems, with the goal of
creating a platform-independent 2 2004: Java 5.0 Release
language for the internet. This version introduced major
improvements, including generics,
annotations, and the enhanced for
2014: Java 8 Release 3 loop.
Java 8 brought lambda
expressions, streams, and other
functional programming features,
making the language more
expressive and concise.
Java Syntax and Basic Concepts
Methods and
1 Syntax 2 Classes and Objects 3 Parameters
Java has a strict and Java is an object- Java methods are
verbose syntax, with oriented language, used to encapsulate
keywords, braces, and all code is and execute specific
and semicolons used organized into tasks, with
to define the classes, which serve parameters passed to
structure of the code. as templates for provide input data.
creating objects.
Data Types and Variables
Primitive Data Types
Java has eight primitive data types, including
integers, floating-point numbers, booleans, and
characters.
Switch Statements
Switch statements provide a more concise way to handle multiple
conditions, evaluating a single expression.
Loops
Looping constructs, such as for, while, and do-while, allow you to
repeatedly execute a block of code.
Java Classes and Objects
Classes Java programs are built using classes,
which serve as templates for creating
objects. Classes define the properties
and behaviors of objects.
Objects Objects are instances of classes, and
they can have their own state (data) and
behavior (methods).