Operator Precedence In Java Examples

Chapter: Operators Last Updated: 17-06-2016 03:39:13 UTC

Program:

            /* ............... START ............... */
                
public class JavaOperatorPrecedenceExample {

	public static void main(String[] args) {
		System.out.println(3 + 3 * 2);
		System.out.println(3 * 3 - 2);
		System.out.println(3 * 3 / 2);
		System.out.println("--");

		System.out.println(1 * 1 + 1 * 1);
		System.out.println(1 + 1 / 1 - 1);
		System.out.println(3 * 3 / 2 + 2);
		System.out.println("--");

		int x = 1;
		System.out.println(x++ + x++ * --x);

		x = 1;
		System.out.println(x << 1 * 2 >> 1);

		x = 0xf;
		System.out.println(0xf & 0x5 | 0xa);
	}
}
                /* ............... END ............... */
        

Output

9
7
4
--
2
1
6
--
5
2
15

Tags

Operator Precedence, Java , Java Basics

Similar Programs Chapter Last Updated
Java Left Shift Operator Operators 04-09-2018
Java Addition Operator Operators 18-05-2017
Java Right Shift Operator Operators 13-12-2016
Prefix Operator In Java Example Operators 19-06-2016
Logical Operators In Java Example Operators 17-06-2016
Ternary Operators In Java Example Operators 15-07-2016
Relational Operators In Java Example Operators 11-06-2016
Modulus Operators In Java Example Operators 15-07-2016
Increment And Decrement In Java Example Operators 15-07-2016
Boolean Operator In Java Example Operators 15-07-2016
Bitwise Operator In Java Example Operators 16-06-2017
Assignment Operation In Java Example Operators 06-04-2016
Arithmetic Operation In Java Example Operators 11-06-2016

1