How to convert Java radix

Convert from decimal to n

int x = 11;
int baseNumber = 2;
String result = Integer.toString(x, baseNumber);
System.out.println(result); // 1011

Convert from n-ary to decimal

String x = "1e"; // 1e =Hexadecimal
int baseNumber = 10;
int result = Integer.parseInt(x, baseNumber);
System.out.println(result); // 30

Recommended Posts

How to convert Java radix
[Java] How to use Map
How to lower java version
[Java] How to use Map
Convert Java Powerpoint to XPS
How to uninstall Java 8 (Mac)
How to use java Optional
How to minimize Java images
How to write java comments
How to use java class
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to display Wingdings
[Java] How to use string.format
How to use Java Map
How to set Java constants
How to use Java variables
[Java] Convert ArrayList to array
[Java] How to implement multithreading
[Java] How to use Optional ①
How to initialize Java array
How to convert A to a and a to A using AND and OR in Java
How to convert a file to a byte array in Java
How to study Java Silver SE 8
How to use Java HttpClient (Get)
Studying Java # 6 (How to write blocks)
[Java] How to update Java on Windows
How to make a Java container
How to disassemble Java class files
How to use Java HttpClient (Post)
[Java] How to use join method
[Processing × Java] How to use variables
[Java] How to create a folder
How to decompile java class files
[Java] How to use LinkedHashMap class
How to convert LocalDate and Timestamp
[JavaFX] [Java8] How to use GridPane
How to write Java variable declaration
How to use class methods [Java]
[Java] How to use List [ArrayList]
How to name variables in Java
How to pass Oracle Java Silver
How to turn Iterator Dojo (Java)
java Eclipse How to debug javaScript
[Android] Convert Android Java code to Kotlin
[Processing × Java] How to use arrays
How to make a Java array
How to use Java lambda expressions
[Java] Convert array to ArrayList * Caution
[Java] How to use Math class
How to find Java prime numbers
How to use Java enum type
How to concatenate strings in java
[Java] How to convert a character string from String type to byte type
For Java beginners: List, Map, Iterator / Array ... How to convert?
How to check Java installed on Mac
How to implement date calculation in Java
How to implement Kalman filter in Java
Multilingual Locale in Java How to use Locale
[Java] How to use the File class
How to compile Java with VsCode & Ant