Java String Function getBytes()
The java string getBytes() method returns the byte array of the string. In other words, it returns sequence of bytes.
Java String getBytes() method example
public class StringGetBytesExample{
public static void main(String args[]){
String s1="ABCDEFG";
byte[] barr=s1.getBytes();
for(int i=0;i < barr.length;i++){
System.out.println(barr[i]);
}
}}
Output:
65 66 67 68 69 70 71java java string