in the name of allah
Can any one explain how to return an arrray from method with type char ..
thanks all
in the name of allah
Can any one explain how to return an arrray from method with type char ..
thanks all
إما أن السؤال أبسط من أن يجاوب
وإما أنك تحتاج إلى توضيح للسؤال
على العموم ربما هكذا
return new char[5]
الله معك
Here you are an example of doing that:
public class ReturnCharArray {
public static char[] to_chars(String w)
{
char[] arr = w.toCharArray();
return arr;
}
public static void main(String[] args) {
String word = "This is a TEST";
char[] chars = to_chars(word);
for(int i = 0; i < chars.length; i++)
System.out.println (chars);
}
}The idea is to send back the name of the array (only the name without the [] ) .
All the best
تم تعديل هذه المشاركة بواسطة بنت اليمن في 25 فبراير 2008 في 10:27
لا اله الا الله .. محمد رسول الله
(* ربِ اجعلني مقيم الصلاة و من ذريتي ، ربنا و تقبل دعـاء *)
يا حيّ يا قيـوم ... برحمتك استغيث ... اصلح لي شأني كله و لا تكلني الى نفسي طرفة عين
اقتباسإما أن السؤال أبسط من أن يجاوبوإما أنك تحتاج إلى توضيح للسؤال
على العموم ربما هكذا
كودreturn new char[5]
الله معك
هو السؤال يمكن بسيط لحد دارسها
انا لسا بدأه فيها كهوايه او للمعرفه مش اكتر ومش مشكله ان سؤالي طلع اسهل من معرفتك او ميستاهلش انه يتجاوب
واظن المنتدي اصلا معمول عشان اللي محتاج حاجه يسأل فيها كان ممكن متجاوبش اساسا
اقتباسThe idea is to send back the name of the array (only the name without the [] ) .
جزاك الله خيرا انا فعلا كنت بضيف ال []