String d1 = " cool ";
byte buf [ ] = d1.getBytes ( ) ;
for ( int i=0; i < buf.length; i++ )
{
System.out.println ( " Index " + i + "is : " + buf [ i ] ) ;
}
public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
//Use getChars ( ) to copy from one string to another string:
src = "Good Morning! How are you?";
char dest [ ] = new char [ src.length ( ) ] ;
src.getChars ( 0, src.length ( ) , dest, 0 ) ;
System.out.println ( " Source string: " + src ) ;
System.out.print ( " Destination string: " ) ;
for ( int i = 0; i < dest.length; i++ )
System.out.print ( dest [ i ] ) ;
RESULT:
=======
Source string: Good Morning! How are you?
Destination string: Good Morning! How are you?
Read more: http://kickjava.com/777.htm#ixzz1JMVCzfBc