import java.io.UnsupportedEncodingException;
public class ByteArray {
public static void main(String[] args) {
byte bt[]={'m','y',' ','n','a','m','e',' ','i','s',' ','r','a','m'};
String str=new String(bt,1,12);
System.out.println("String is "+str);
StringBuffer strBuf = new StringBuffer("Hello");
String str2 = strBuf.append("Java").toString( );
System.out.println("String is "+str2);
String str3 = new String(new char[]{'a','b','c'});
System.out.println("String is "+str3);
String str4 = "Java was developed by James Ghosling";
System.out.println(str4.substring(19));
String str5=new String("hello");
System.out.println(str5.replace('l', 'L'));
System.out.println(str5);
}
}
public class ByteArray {
public static void main(String[] args) {
byte bt[]={'m','y',' ','n','a','m','e',' ','i','s',' ','r','a','m'};
String str=new String(bt,1,12);
System.out.println("String is "+str);
StringBuffer strBuf = new StringBuffer("Hello");
String str2 = strBuf.append("Java").toString( );
System.out.println("String is "+str2);
String str3 = new String(new char[]{'a','b','c'});
System.out.println("String is "+str3);
String str4 = "Java was developed by James Ghosling";
System.out.println(str4.substring(19));
String str5=new String("hello");
System.out.println(str5.replace('l', 'L'));
System.out.println(str5);
}
}
0 comments:
Post a Comment