Pages

Sunday, March 16, 2014

Binary Hex and Octal Conversion in Java | Example | Source code

Written by Pranshu Bajpai |  | LinkedIn

Source Code



package DICAss;

class DICAss7_Conversion
{
	public static void main(String[] args)
	{
		String binary = "111";
		String hex = "A";
		String oct = "772";

		int decimal1 = Integer.parseInt(binary, 2);

		int decimal2 = Integer.parseInt(hex, 16);

		int decimal3 = Integer.parseInt(oct, 8);

		System.out.println(decimal1);
		System.out.println(decimal2);
		System.out.println(decimal3);

	}	
}

No comments:

Post a Comment