I am writing a program that switches a binary number into a decimal number and am only a novice programmer. I am stuck trying to determine that the string that was entered is a
You could just use a regular expression:
num.matches("[01]+")
This will be true if the string num contains only 0 and 1 characters, and false otherwise.
true
num
0
1
false