Java lecture 6 Operators in Java

  THE ROYAL GROUP OF PAK



JAVA LECTURE 6 (Operators)

For this video tutorial or full java, course visit YouTube Channel 

Video
To watch the video tutorial scroll down 

Channel link

Operators are used to performing operations on variables and values.

In the example below, we use the + operator to add together two values:

Types of Operators in Java:

1.     Arithmetic Operators 
            Arithmetic operators are used to performing common mathematical operations.

2.     Assignment Operators
            Assignment operators are used to assigning values to variables.

In the example below, we use the assignment operator (=) to assign the value 10 to a variable called B:

3.    Comparison Operators
            Comparison operators are used to comparing two values. This is important in programming because it helps us to find answers and make decisions.

The return value of a comparison is either true or false. These values are known as Boolean values.

In the following example, we use the greater than operator (>) to find out if 5 is greater than 3:


4.    Logical Operators
            You can also test for true or false values with logical operators.

Logical operators are used to determining the logic between variables or values:

5.    Bitwise Operators

More detail and explanation are in the video go and watch 👈




Here is the code for test purposes you can copy and paste it for practice 

public class RGP_06_Operators {
public static void main(String[] args) {
// Arithmetic Operator
int a = 20 + 5;
System.out.println(a);
// Assignment Operator
int b = 30;
b -= 5;
System.out.println(b);
// Comparison Operators
int x = 5;
int y = 5;
System.out.println(x != y);

// Logical Operators
int c = 5;
System.out.println(!(c < 7));
//Qiuz

// Multiply 10 with 5, print the result.


}
}

Comments

Popular Posts