Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Program to show an example of creating Character Arrays from String objects

Posted By: Andre Allen     Category: Java     Views: 8104

A Java Program to show an example of creating Character Arrays from String objects.

Code for Program to show an example of creating Character Arrays from String objects in Java

publicclass JAVA_054
 {

    publicstaticvoid main(String[] args)
    {
       String Str="To be or not to be";

       char[] cArray_1=Str.toCharArray( );
       char[] cArray_2=newchar[6];

       Str.getChars(9,15,cArray_2,0);

       System.out.println("The String is : " + Str);

       System.out.println("The character Array-1 is : ");

       for(int i=0;i<cArray_1.length;i++)
          System.out.println(cArray_1[i]);

       System.out.println("The character Array-2 is : ");

       for(int j=0;j<cArray_2.length;j++)
          System.out.println(cArray_2[j]);
    }
 }
  
Share: 



Andre Allen
Andre Allen author of Program to show an example of creating Character Arrays from String objects is from Houston, United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!