Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

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

Posted By: Leland Hughes     Category: Java     Views: 1548

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

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

publicclass JAVA_055
 {

    publicstaticvoid main(String[] args)
    {
       char[] cArray={'T','o',' ','b','e',' ','o','r',' ','n','o','t',
                      ' ','t','o',' ','b','e'};

       String Str1=String.copyValueOf(cArray);
       String Str2=String.copyValueOf(cArray,9,6);

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

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

       System.out.println("\nThe String-1 is : " + Str1);
       System.out.println("The String-2 is : " + Str2);
    }
 }
  
Share: 



Leland Hughes
Leland Hughes author of Program to show an example of creating String objects from Character Arrays is from New York, 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!