fork download
  1. class Main{
  2. public static void main(String[] a){
  3. String s = "0400";
  4. int i = Integer.parseInt(s);
  5. System.out.println("From: \""+s+"\"; to: "+i);
  6.  
  7. int n = 0400;
  8. String asOctal = Integer.toString(n, 8); // Convert from base-8 to base-10
  9. int asDecimal = Integer.valueOf(asOctal); // Base-10 by default
  10. System.out.println("From: "+n+" (base-8 integer); to: \""+asOctal+"\" (base-10 as String) or "+asDecimal+" (base-10 as integer)");
  11. }
  12. }
Success #stdin #stdout 0.22s 37548KB
stdin
Standard input is empty
stdout
From: "0400"; to: 400
From: 256 (base-8 integer); to: "400" (base-10 as String) or 400 (base-10 as integer)