Skip to content

Instantly share code, notes, and snippets.

@msomu
Created October 31, 2014 14:21
Show Gist options
  • Select an option

  • Save msomu/cab8d4efbc1f8eb1ed60 to your computer and use it in GitHub Desktop.

Select an option

Save msomu/cab8d4efbc1f8eb1ed60 to your computer and use it in GitHub Desktop.
Inc dec operators
import java.util.Scanner;
public class IncrementOperator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int pen = 5;
int pencil = 1;
//Post increment
System.out.println(pen++);
System.out.println(pen);
//Pre increment
System.out.println(++pencil);
// add n to it
pencil +=10;
System.out.println(pencil);
// mul n to it
pencil *=10;
System.out.println(pencil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment