0% found this document useful (0 votes)
3 views12 pages

Java Operators PDF

Java is a high-level, object-oriented programming language that is platform-independent and follows the WORA principle. The Java Development Environment includes the JVM, JRE, and JDK, which are essential for compiling and running Java applications. Operators in Java are categorized into seven types, including arithmetic, relational, logical, assignment, unary, ternary, and bitwise operators, each serving specific functions in programming.

Uploaded by

rathinakumari.a
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Java Operators PDF

Java is a high-level, object-oriented programming language that is platform-independent and follows the WORA principle. The Java Development Environment includes the JVM, JRE, and JDK, which are essential for compiling and running Java applications. Operators in Java are categorized into seven types, including arithmetic, relational, logical, assignment, unary, ternary, and bitwise operators, each serving specific functions in programming.

Uploaded by

rathinakumari.a
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Operators

Java Programming Basics

• Java is a high-level, class-based, and object-oriented programming language widely used for
developing web, desktop, and enterprise applications. It follows the “Write Once, Run Anywhere”
(WORA) principle, allowing Java programs to run on any platform with a Java Virtual Machine (JVM).

• Platform-independent language supported by the JVM.

• Provides object-oriented features such as inheritance, polymorphism, and encapsulation.

• Known for its security, portability, and robust memory management.


Java Development Environment

• The Java Development Environment is required to compile and run Java programs on a system. It
involves installing the JDK and configuring environment variables like PATH and JAVA_HOME
so the system can access Java tools properly. environment variables(such as PATH and
JAVA_HOME).

• The development environment of Java consists of three main components:

• JVM (Java Virtual Machine): JVM is the engine that executes Java programs. It converts Java
bytecode into machine code that the operating system can understand.

• JRE (Java Runtime Environment): JRE provides the environment required to run Java
applications. It includes JVM and the necessary libraries and supporting files.

• JDK (Java Development Kit): JDK is used for developing Java applications. It includes JRE
along with development tools such as the Java compiler and debugger.
Java Basic Syntax
The syntax defines the rules and structure of how Java code is written and executed. Every Java
program is built using classes, methods, and statements.
Example:
public class HelloWorld
{
public static void main(String[] args)
{
[Link]("Hello, World");
}
}
Output: Hello, World
Explanation:
• public class HelloWorld: Defines a class named HelloWorld.
• public static void main(String[] args): The entry point of the program; execution starts
here.
• [Link]("Hello, World"): Prints the text "Hello, World" followed by a new line.
Operators in Java

Operators are symbols that perform specific operations on one or more operands (variables
or values). They are used to perform calculations, comparisons, logical operations and manipulate
data.

They are basically 7 types:

Arithmetic Operators (+, -, *, /, %) –> Used to perform mathematical calculations on numeric


values.

Relational Operators (==, !=, >, <, >=, <=) –> Used to compare two values and return a boolean
result.

Logical Operators (&&, ||, !) –> Used to combine or reverse boolean conditions.

Assignment Operators (=, +=, -=, *=, /=, %=) –> Used to assign and update variable values.
Unary Operators (+, -, ++, --, !) –> Used to perform operations on a single operand.

Ternary Operator (condition ? value_if_true : value_if_false) –> Used as a shorthand for the if-
else statement.

Bitwise Operators (&, |, ^, ~, <<, >>, >>>) –> Used to perform operations on binary bits of integer
values.
Example:

public class SimpleOperatorsDemo {

public static void main(String[] args) {

int a = 10, b = 3;

[Link] (“Arithmetic Operators”);

[Link]("a + b = " + (a + b)); // Addition

[Link]("a - b = " + (a - b)); // Subtraction

[Link] (“Relational Operators”);

[Link]("a > b ? " + (a > b)); // Greater than

[Link]("a < b ? " + (a < b)); // Less than


[Link] (“Logical Operators”);
boolean x = true, y = false;
[Link]("x && y = " + (x && y)); // Logical AND
[Link]("x || y = " + (x || y)); // Logical OR

[Link] (“Assignment Operators”);


a += 5; // a = a + 5
[Link]("a after += 5 : " + a);

[Link] (“Ternary Operators”);


int max = (a > b) ? a : b;
[Link]("Maximum = " + max);
}
}
Output
Arithmetic Operators
a + b = 13
a - b = 7
Relational Operators
a > b ? True
a < b? False
Logical Operators
x && y = false
x || y = true
Assignment Operators
a after += 5 : 15
Ternary Operators
Maximum = 15

You might also like