Thursday, 12 June 2014

String (byte[] bytes)

public String(byte[] bytes)
Constructs a new String by decoding the specified array of bytes using the platform's default charset. 

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



 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment