Tuesday 24 June 2014

valueOf (char[] data, int offset, int count)

public static String valueOf(char[] data, int offset, int count)
Returns the string representation of a specific subarray of the char array argument.

offset : index of the first character of the subarray
count : specifies the length of the subarray

class StringValueOfCharArrayLength{
 public static void main(String args[]){
  char arr[] = {'d', 'e', 'f', 'g', 'h', 'i', 'j'};
  
  String str1 = String.valueOf(arr, 2, 3);
  
  System.out.println("str1 = " + str1);
 }
}

Output
str1 = fgh




 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment