How to convert binary to decimal in java

```public static int integerfrmbinary(String str){
double j=0;
for(int i=0;i<str.length();i++){
if(str.charAt(i)== '1'){
j=j+ Math.pow(2,str.length()-1-i);
}

}
return (int) j;
}```

--------------------------------------------------------------------------------------

Other Way:

```import java.lang.*;
import java.io.*;

public class BinaryToDecimal{
public static void main(String[] args) throws IOException{
System.out.print("Enter the Binary value: ");
long num = Long.parseLong(str);
long rem;
while(num > 0){
rem = num % 10;
num = num / 10;
if(rem != 0 && rem != 1){
System.out.println("This is not a binary number.");
System.exit(0);
}
}
int i= Integer.parseInt(str,2);
System.out.println("Decimal:="+ i);
}
}```
```
```
```
```
```run:
Enter the Binary value: 1010
Decimal:=10```
```
```
`--------------------------------------------`
```
```
```java - How to convert binary string value to decimal
Java Convert Binary to Decimal,Binary to Decimal
How to convert binary to decimal?
Convert from binary to decimal?
HOW TO CONVERT BINARY TO DECIMAL USING JAVA PROGRAM
How do you convert a decimal number to binary in java?
How to write a java program that converts binary to
How to write a java program to convert binary to
Java program to convert binary,octal,decimal to
Java Program Convert Binary to Decimal
Decimal To Binary Converter - Java Tutorials
Binary To Decimal Conversion - Java
Searches related to java Convert Binary to Decimal
javascript convert binary decimal
java convert binary integer
java convert binary to decimal program
java program that converts binary to decimal
decimal to binary java code
java binary string to decimal
convert a number to binary java```

1. But you are cheating you asshole

2. this is helpful thank you

3. Really Nice Information,Thank You Very Much For Sharing.
Web Designing Company

4. see this link for one more proram :-

Programmers interview

1. see this link : -

http://www.programmersinterview.com/2015/10/java-program-convert-binary-to-decimal.html