java.lang.Byte.valueOf(String s, int radix)


java.lang.Byte.valueOf(String s, int radix)

package com.codingdict;



import java.lang.*;



public class ByteDemo {



   public static void main(String[] args) {



      // create a String s and assign value to it

      String s = "-1010";



      // create a Byte object b

      Byte b;



      /**

       *  static method is called using class name.

       *  assign Byte instance value of s to b using radix as 2

       *  radix 2 represents binary

       */

      b = Byte.valueOf(s, 2);



      String str = "Byte value of string " + s + " using radix 2 is " + b;



      // print b value

      System.out.println( str );

   }

}