Java getChars method with getBytes method

Java getChars method stores string data into character array. We can copy all string and also part of string.

Java getBytes method stores string data into byte array. We can find ASCII code from this function.


Let’s see example on java getChars method


class str8


                public static void main(String args[])


                                String str1 = “Gandhinagar is State”;

                                String str2 = “Gujarat is City”;

                                char storeString[] = new char[50];



                                // 0 – start index of str1 -> G

                                // 14 – end index of str1 -> s

                                // storeString -> array name

                                // 0 – start index of storeString array





                                // 10 – start index of str2 -> _City

                                // 15 – end inde of str2 -> y

                                // storeString – char array

                                // 15 – inde of storestring array







Gandhinagar is

Gandhinagar is City


Video on getChars method


If you have any query on blog example, you can directly comment us or subscribe our website

Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

303total visits,3visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.


Link back if you want.

Enter Captcha Here :*

Reload Image