- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to convert binary number to decimal value
The java.lang.Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.
The parseInt(String str, radix r) method of the Integer class parses the given string argument as a signed integer in the radix specified by the second argument and returns it.
Example
import java.util.Scanner; public class BinaryToDecimal { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter a binary number ::"); String binary = sc.next(); int decimal = Integer.parseInt(binary, 2); System.out.println("Decimal value of the given binary number is ::"+decimal); } }
Output
Enter a binary number :: 101001 Decimal value of the given binary number is ::41
- Related Articles
- Java program to convert decimal number to binary value
- Java Program to convert binary number to decimal number
- Java program to convert decimal number to octal value
- C++ Program To Convert Decimal Number to Binary
- Python program to convert decimal to binary number
- Java Program to convert from decimal to binary
- Convert decimal to binary number in Python program
- Java program to convert decimal number to hexadecimal number
- Java Program to convert hexadecimal number to decimal number
- Java Program to convert octal number to decimal number
- C++ program to Convert a Decimal Number to Binary Number using Stacks
- Haskell program to convert a decimal number into a binary number
- Convert Decimal to Binary in Java
- C++ Program to Convert Binary Number to Decimal and vice-versa
- Swift program to convert the decimal number to binary using recursion

Advertisements