Java Data Type Tutorial - Java String.getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)








Syntax

String.getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) has the following syntax.

@Deprecated public void getBytes(int srcBegin,   int srcEnd,   byte[] dst,   int dstBegin)

Example

In the following code shows how to use String.getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) method.

//w w w  . jav  a2  s.  co m
public class Main {

  public static void main(String[] args) {
  
    String str = "java2s.com";
    System.out.println(str);
    
    char[] chararr = new char[30];
   
    str.getChars(2, 6, chararr, 0);

    System.out.print("Value of character array : ");
    System.out.println(chararr);
  }
}

The code above generates the following result.