Initialize a string variable with a string value, convert it into bytes and again convert it back to a string , print it.
Output:
Output:
Input String is : I am CodeRegister.in !
Input String in byte format is : [B@106d69c
Byte to string format : I am CodeRegister.in !
Java Implementation:
import java.util.*;
import java.lang.*;
import java.io.*;
class CodeRegister
{
public static void main (String[] args) throws java.lang.Exception
{
String str = "I am CodeRegister.in !";
byte[] bytes = str.getBytes();
System.out.println("Input String is : "+str);
System.out.println("Input String in byte format is : "+bytes);
//converting from bytes to string again
String toString = new String(bytes);
System.out.println("Byte to string format : "+toString );
}
}