public class Try{
        public static void main(String args[]){
            String hex="11000010111100001001111010111000";
             String HexaBin="";
                for (int i = 0; i < hex.length(); i+=4) {
                    String str = hex.substring(i, i+4);
                    if (str=="0000")
                        HexaBin+= "0";
                    else if (str=="0001")
                        HexaBin+="1";
                    else if(str=="0010")
                        HexaBin+="2";
                    else if(str=="0011")
                        HexaBin+="3";
                    else if(str=="0100")
                        HexaBin+="4";
                    else if(str=="0101")
                        HexaBin+="5";
                    else if(str=="0110")
                        HexaBin+="6";
                    else if(str=="0111")
                        HexaBin+="7";
                    else if(str=="1000")
                        HexaBin+="8";
                    else if(str=="1001")
                        HexaBin+="9";
                    else if(str=="1010")
                        HexaBin+="A";
                    else if(str=="0000")
                        HexaBin+="B";
                    else if(str=="1100")
                        HexaBin+="C";
                    else if(str=="1101")
                        HexaBin+="D";
                    else if(str=="1110")
                        HexaBin+="E";
                    else if(str=="1111")
                        HexaBin+="F";
                }
                   System.out.println(HexaBin);
            }
        }
I have a string containing binary numbers. I need to convert it to Hexadecimal without using any built in function. I tried these codes but it wont run. I don't know why.
When I run it, it gets terminated. what's the problem with these codes.
 
     
     
     
     
     
    