Directly on the code:
public class Main {public static void main (string[] args) {//TODO auto-generated method StubSystem.out.println ("decimal conversion to other input System: "); int x = 123; String str1 = integer.tohexstring (x); 10 binary converted to 16 binary string System.out.println (STR1); String str2 = integer.tooctalstring (x); 10 binary converted to 8 binary string System.out.println (STR2); String STR3 = integer.tobinarystring (x); 10 binary converted to 2 binary string System.out.println (STR3); String STR4 = integer.tostring (123456,7); 10 binary converted to 7 binary string///string STR4 = integer.tostring (i,x); The 10 binary number I is converted to the X-binary string System.out.println ("Other system converts to decimal:"), int y1= integer.valueof ("FFFF", 16); 16 binary converted to 10 binary System.out.println (y1), int y2=integer.valueof ("776", 8); 8 binary converted to 10 binary System.out.println (y2), int y3=integer.valueof ("0101", 2); 2 binary converted to 10 binary System.out.println (y3), int y4=integer.valueof ("101", 7); 7 binary converted to 10 binary System.out.println (y4);///integer.valueof ("str", x); You can convert any string str into an X-System.out.println ("Other possible function:"),//static int parseint (string s, int radix)// Uses the cardinality specified by the second argument to resolve the string argument toA signed integer. int n = integer.parseint ("776", 8); 8 binary to 10 binary System.out.println (n);///integer.valueof () returns an "Integer object" and Integer.parseint () returns an "int value" difference in that the return value is different Basic knowledge, other non-10 binary number of the save, basically are in the form of a string///Example: 7 to 8 binary conversion string q = "6523"; 7 binary strings String b = integer.tostring (integer.valueof (q,7), 8);///So 7 binary becomes 8 binary}}
Any conversion between Java and any binary