Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
try{
java.math.BigInteger bI = new java.math.BigInteger(<String>, 2);
}catch( NumberFormatException e){
...
}
public class Main {
public static void main (String[]args){
String str = "1001";
char[] c_array = new char[str.length()];
c_array = str.toCharArray();
for(int i=0; i<str.length(); i++){
if(c_array[i] != (char) 0 && c_array[i] != (char) 1 ){
System.out.println("Bitte eine Binärzahl eingeben");
break;
}
}
}
}
public class Main {
public static void main (String[]args){
String str = "110011"; //Zu Ueberpruefender String
System.out.println(isItBinary(str)); //Function Aufruf und Ausgabe
}
private static boolean isItBinary(String str) {
boolean b = true;
for(int i=0; i<str.length(); i++){
//Ueberprüfung: Wenn nicht Binarystring
if (str.charAt(i) != '0' && str.charAt(i) != '1'){
b = false;
return b;
}
}
return b;
}
}