Java-Arithmetic Operators

Operators An operator is a symbol that takes one or more arguments and operates on them to produce a result. Operators are used in programs to manipulate data and variables. Arithmetic Operators  Arithmetic operators are used to construct mathematical expressions. The usual arithmetic operator +, -, *, / are used in java for addition, subtraction, … Read more…

Java-Modulus Operator

Modulus Operator  The modulus operator %, returns the remainder of a division operation. If can be applied to floating-point types as well as integer types. Program Program Source class Javaapp { public static void main(String[] args) { int a = 55; System.out.println(“a mod 10 = “+a%10); } }

Java-Arithmetic Compound Assignment Operators

Arithmetic Compound Assignment Operators Java provides special operators that can be used to combine an arithmetic operation with an assignment. As you probably know, statements like the following are quite common in programming : In Java, you can rewrite this statement as shown here : This version uses the += compound assignment operator. Both statements … Read more…

Java-Increment and Decrement Operators

Increment and Decrement operators Java has two very useful operators. These are the increment and decrement operators : The operators ++ adds 1 to the operand while – – subtracts 1. For example, the code changes ‘totel’ to 6. Because these operators change the value of ‘totel‘ variable, they cannot be applied to numbers themselves. … Read more…

Java-Relational Operators

Relational Operators We often compare two quantities, and depending on their relation, take certain decisions. For example, we may compare the age of two persons, or the price of two items, and so on. These comparisons can be done with the help of relational operators. The value of relational expression is either true or false. … Read more…

Java-Boolean Logical Operators

Boolean Logical Operators The Boolean logical operators are used when we want to form compound conditions by combining two or more relations. Operator Meaning | Logical OR & Logical AND ^ Logical XOR ! Logical NOT The following table shows the effect of each logical operation : A B A | B A & B A … Read more…