The main thing is: how that binary for example 11110000 is divided into two parts such as s1=1111 and s2=0000. I have to do this in Java

First, read the string from keyboard

Scanner scanner = new Scanner(System.in);
String s1 = scanner.nextLine();
String s2 = scanner.nextLine();

Then, you have two steps. First, concatenate the two string to get one

 String s = s1 + s2;

And then, parse the value to create an integer. I assume you mean that you want to convert it to the respective decimal, since it’s already binary. In that case

int result = Integer.parseInt(s, 2);

Leave a Comment