طريقة Java String copyValueOf ()
مثال
قم بإرجاع سلسلة تمثل أحرفًا معينة من مصفوفة أحرف:
char[] myStr1 = {'H', 'e', 'l', 'l', 'o'};
String myStr2 = "";
myStr2 = myStr2.copyValueOf(myStr1, 0, 5);
System.out.println("Returned String: " + myStr2);
التعريف والاستخدام
تقوم copyValueOf()
الطريقة بإرجاع String
حرف يمثل أحرف مصفوفة char.
تعيد هذه الطريقة String
مصفوفة جديدة وتنسخ الأحرف فيها.
بناء الجملة
public static String copyValueOf(char[] data, int offset, int count)
قيمه المعامل
Parameter | Description |
---|---|
data | A char array |
offset | An int value, representing the start
index of the char array |
count | An int value, representing the length
of the char array |
تفاصيل تقنية
عائدات: | A String ، يمثل أحرف مصفوفة char |
---|---|
رميات: | StringIndexOutOfBoundsException - إذا كانت الإزاحة سالبة أو بعيدة المنال ، أو إذا كان العدد أكبر من طول مصفوفة الأحرف ، أو سالب |
❮ طرق السلسلة