AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Java Operators


Java Tutorial » Java Operators

Operators as : sum, multiplied, decrease , etc... are used to perform operations on variables and values.

In the below example, we use sum, multiplied, decrease and division operator to see how it is working:
Example:
public class Main {
public static void main(String[] args) {
int x = 100 + 50; // sum
int y = 10 * 50; // multiplied
int z = 10 - 5; // decrease
int w = 10 / 5; // division
System.out.println(x);
System.out.println(y);
System.out.println(z);
System.out.println(w);
}
}
Output:
150
500
5
2


Arithmetic Operators


For variable X holds 15 and variable Y holds 25,

+ (Addition) Adds values. X + Y will give 40
- (Subtraction) Subtracts one value from another. X - Y will give -10
* (Multiplication) Multiplies values. X * Y will give 375
/ (Division) Divides one value by another. Y / X will give 1
% (Modulus) Returns the division remainder. Y % X will give 10
++ (Increment) Increases the value of operand by 1. X++ gives 16
-- (Decrement) Decreases the value of operand by 1. X-- gives 14

Example: assign value

public class Main {
public static void main(String[] args) {
int y = 24;

//adds a value to a variable
int z = 33;
z +=10 ;

//Subtract a value to a variable
int w = 33;
w -=10 ;

//Multiplay
int t = 40;
t *=10 ;

//Divide
int s = 33;
s /=11 ;
//

System.out.println(y);
System.out.println(z);
System.out.println(w);
System.out.println(t);
System.out.println(s); }
}
Output:
24
43
23
400
3


Java Comparison Operators


Comparison operators java are used to compare two values:

Example:
public class Main {
public static void main(String[] args) {
int z = 14;
int w = 7;
System.out.println(z == w); // Equal to - false because 14 is not equal to 7
System.out.println(z != w); // Not equal - true because 14 is not equal to 7
System.out.println(z > w); // Greater than - true because 14 is greater than 7
System.out.println(z < w); // Less than - false because 14 is not less than 7
System.out.println(z >= w); // Greater than or equal to - true because 14 is greater, or equal,to 7
System.out.println(z <= w); // Less than or equal to - false because 14 is neither less than or equal to 7
}
}
Output:
false
true
true
false
true
false




Java Operators list, oder of precedence, overloading, table, precedence table, overloaded for string objects, exercises, example
Java Operators - java

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Upload Image, display, edit and delete i...
Login Form with Image background...
How to Create an Image with Transparent ...
Portfolio Gallery Website with filtering...
Simple pagination script PHP MySQLi...
Center Image in div...
Image Hover Overlay Fade...
Sticky image / element / div on scroll...
Responsive images...
Create rounded image in HTML CSS...
Add border around image...
Position Text Over an Image HTML CSS res...
Create a Slideshow Images Gallery...
Create a Sticky Sidebar...
Search bar using CSS HTML...
Shrink Navigation Menu on Scroll...
How to Create Accordion HTML Templates...
Dropdown menu in the navigation bar...
Responsive Top Navigation Bar with mobil...
Split horizontal navigation bar...