Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 19, 2018 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/fa2d85d791f29d970df7610d4ffc18e5 to your computer and use it in GitHub Desktop.
Save thmain/fa2d85d791f29d970df7610d4ffc18e5 to your computer and use it in GitHub Desktop.
public class LeftRightShift {
static void LeftShift(int n){
int x = n<<1;
System.out.println("n<<1, Left shift by 1 of n: "+ n + " is : " + x);
}
static void RightShift(int n){
int x = n>>1;
System.out.println("n>>1, Right shift by 1 of n: "+ n + " is : " + x);
}
public static void main(String[] args) {
int n = 10;
LeftShift(n);
RightShift(n);
n = 62;
LeftShift(n);
RightShift(n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment