```
public class Solution {
public int findComplement(int num) {
String binary = Integer.toBinaryString(num);
int sum=0;
for(int i=0;i<binary.length();i++) {
int val = 2*((binary.charAt(i)-'0')^1);
if(val>0)
sum += Math.pow(val,binary.length()-1-i);
}
return sum;
}
}
```