• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Interview Questions
  • Java
  • Java Programs
  • Selenium
  • Selenium Programs
  • Manual Testing
  • Test Cases
  • Difference
  • Tools
  • SQL
  • Contact Us
  • Search
SoftwareTestingo » Java » Java Programs » How to Copy Specific Array Values into String In Java With Example?

How to Copy Specific Array Values into String In Java With Example?

Last Updated on: November 3, 2018 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • How to Copy Specific Array Values into String In Java With Example?

How to Copy Specific Array Values into String In Java With Example?

package com.java.Softwaretestingblog;
public class Copy_Specific_Array_Values 
{
   public static void main(String[] args) 
{
      // TODO Auto-generated method stub
      char ch[] = {'S','o','f','t','w','a','r','e','T','e','s','t','i','n','g','B','l','o','g'}; 
      /** * We can copy a char array to a string by using * copyValueOf() method. */ 
      String chStr = String.copyValueOf(ch); 
      System.out.println("Original Array Values :- "+chStr); 
      /** * We can also copy only range of charactors in a * char array by copyValueOf() method. */ 
      String subStr = String.copyValueOf(ch,8,7); 
      System.out.println("Substring From The Original String :-"+subStr);
   }
}

Output:

Original Array Values :- SoftwareTestingBlog
Substring From The Original String :-Testing

    Filed Under: Java Programs

    Reader Interactions

    Leave a Reply Cancel reply

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

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2022 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers