Java String getBytes()

The java string getBytes() method returns the byte array of the string. In other words, it returns sequence of bytes.

Signature

There are 3 variant of getBytes() method. The signature or syntax of string getBytes() method is given below:


Internal implementation


Returns

sequence of bytes.


Java String getBytes() method example

Test it Now

Output:

65
66
67
68
69
70
71

Java String getBytes() Method Example 2

This method returns a byte array that again can be passed to String constructor to get String.

Test it Now

Output:

65
66
67
68
69
70
71
ABCDEFG




Contact US

Email:[email protected]

String getBytes()
10/30