Thursday, 12 June 2014

Convert Byte Array to String


class StringConstructor2{
 public static void main(String args[]){
  byte data[] = new byte[26];
  String s1;
  int count = 0;
  
  for(byte b = 97; b < 123; b++){
   data[count] = b;
   count++;
  }
  
  s1 = new String(data);
  System.out.println("s1 = " +s1);
 }
}

Output
s1 = abcdefghijklmnopqrstuvwxyz


                                                             Home

No comments:

Post a Comment