You are here: Home / Topics / Make string using ASCII value in Java

Make string using ASCII value in Java

Filed under: Java on 2023-08-23 06:57:05

// Program to explain the following String function :
// String( byte asciiChars[ ] )

class  MString4
{
public static void main( String args[ ] )
{
 char ch[ ] = { 'J', 'A', 'V', 'A' };
 String s1 = new String( ch );

 byte b[ ] = { 65, 66, 67, 68, 69, 70 };
 String s2 = new String( b );

 System.out.println( " String = " + s1 );
 System.out.println( " String = " + s2 );
}
}


Output:

 String = JAVA
 String = ABCDEF

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.