Sunday, January 31, 2016

PrePostIncrementExample4

package LearnJava;

public class PrePostIncrementExample4 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

int i = 0;

int j = i++ + i+ i;

System.out.println(j);

//output = 2

int k = 0;

int m = k++ + k + k++ + k;

System.out.println(m);

//output = 4
int l = 0;

int p = l-- + l-- + l-- +l;

System.out.println(p);

//output = -6

int o = 0;

int z = ++o + ++o + --o + o-- + o++ +o;

System.out.println(z);

//output = 6


}

}

1 comment:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Core Java Training in Electronic city

    ReplyDelete