-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution_1.java
More file actions
36 lines (32 loc) · 785 Bytes
/
Solution_1.java
File metadata and controls
36 lines (32 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class Solution_1{
public static void even_odd(int n){
int bitmask = 1;
if((n & bitmask) == 0){
System.out.println("Even Number ");
}
else{
System.out.println("Odd Number ");
}
}
public static int get_bit(int n , int i){
int bitmask = 1<<i;
if((n & bitmask) == 0){
return 0;
}
else{
return 1;
}
}
public static int set_bit(int n,int i){
int bitmask =1<<i;
return n | bitmask;
}
public static void main(String[] args){
even_odd(11);
even_odd(3);
int g = get_bit(10,2);
System.out.println(g);
int s =set_bit(10,2);
System.out.println(s);
}
}