Answers for "pre increment and post increment in java with example"

2

java pre increment

//Preincrement
x = 0;
System.out.println(++x); // this prints 1 because increments before execute print
Posted by: Guest on August-10-2021
0

pre increment and post increments java

int x =0;
// POST increments: increments after it prints x or stmt  
System.out.println("Hello World"+ x++); // 0 
System.out.println("Hello World"+ x); // 1

// PRE increments: increments before it prints x or stmt  
System.out.println("Hello World"+ ++x); // 1
System.out.println("Hello World"+ x); // 1
Posted by: Guest on March-21-2022

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language