@@ -11,12 +11,12 @@ In this tutorial, we will see a Java program to check if the given number is bin
1111
1212We can check if the given number is binary or not by the following ways
1313
14- 1 . Checking if number contains ` 1 ` or ` 0 ` digit by the reminder and divide method
14+ 1 . Checking if the number contains a ` 1 ` or ` 0 ` digits by the reminder and divide method
15152 . Convert the number to String
1616
1717## 1. Java program to check if the given number is binary or not by checking if the number contains ` 1 ` or ` 0 ` digit by the reminder and divide method
1818
19- In the below program, we are getting each digits of the given input number one by one using the reminder method.
19+ In the below program, we are getting each digit of the given input number one by one using the reminder method.
2020
2121If the digit is any other than the ` 0 ` and ` 1 ` , i.e. number is not Binary and it returns ` false ` . Otherwise, it will return ` true ` .
2222
@@ -55,16 +55,16 @@ public class BinaryChecker {
5555101110001 is a binary number.
5656```
5757
58- ## 2. Java program to check if the given number is binary or not by converting the number to String
58+ ## 2. Java program to check if the given number is binary or not by converting the number to a String
5959
60- In the below program we have used regex expression to check if the number has only ` 0 ` or ` 1 ` digits.
60+ In the below program, we have used the regex expression to check if the number has only ` 0 ` or ` 1 ` digits.
6161
6262We can do it as follows
6363
64641 . We are converting the given input number to a string
6565
66662 . Using the regex pattern matcher to check whether the number string i.e. ` inputStr ` contains only ` 0 ` or ` 1 ` digits.
67- 3 . If we found any ` 0 ` or ` 1 ` in the number, the number is binary and it returns ` true ` , Otherwise it returns ` false `
67+ 3 . If we find any ` 0 ` or ` 1 ` in the number, the number is binary and it returns ` true ` , Otherwise it returns ` false `
6868
6969** Java Program**
7070
@@ -106,4 +106,4 @@ public class BinaryChecker2 {
106106
107107```
10810810110101 is a binary number.
109- ```
109+ ```
0 commit comments