You are here: Home / Topics / Increment Operator Example in Java

Increment Operator Example in Java

Filed under: Java on 2023-08-11 19:25:04

// Increment Operator example

class  IncrementOperatoeExample
{
public static void main( String args[ ] )
{
 int a = 10, b = 20 ,c;
 
 c = ( ++a ) + ( ++b );
 
 // a++ is Post fix increment
 // ++b is pre fix increment
 
 System.out.println( " Value of a = " + a );
 System.out.println( " Value of b = " + b );
 System.out.println( " Value of c = " + c );
}
}


Output:

Value of a = 11
Value of b = 21
Value of c = 32

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.