A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/java/lang/string_copyvalueof_count.htm below:

Java.lang.String.copyValueOf() Method

Java.lang.String.copyValueOf() Method Description

The java.lang.String.copyValueOf(char[] data, int offset, int count) method returns a String that represents the character sequence in the array specified.

Declaration

Following is the declaration for java.lang.String.copyValueOf() method

public static String copyValueOf(char[] data, int offset, int count)
Parameters Return Value

This method returns a String that represents the character sequence in the array specified.

Exception

NA

Example

The following example shows the usage of java.lang.String.copyValueOf() method.

package com.tutorialspoint;

import java.lang.*;

public class StringDemo {

   public static void main(String[] args) {

      // character array
      char[] charArr = { 'C', 'O', 'M', 'P', 'I', 'L', 'E', ' ',
         'O', 'N', 'L', 'I', 'N', 'E' };

      /* returns a String that contains the characters of the character
         array with offset as 8 and length as 6 */
      String str = String.copyValueOf(charArr, 8, 6 );

      // prints the substring with length as 6 
      System.out.println(str);
   }
}

Let us compile and run the above program, this will produce the following result −

ONLINE

java_lang_string.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4