[android-developers] Re: help me urgent
sree wrote: i [sic] gave two single dimensional arrays one array prioritynamearray=alistpriorityname.toArray(new String[alistpriorityname.size()]); two array taskvaluesarray=taskvaluesarraylist.toArray(new String[taskvaluesarraylist.size()]); The above code i take two ArrayList and convert two single dimensional arrays, now i need these two seperate arrays as two dimensional array. how please convert it and give solution, First, Java doesn't actually have two-dimensional arrays. What is does have is one-dimensional arrays each of whose elements is an array, declared similarly to Foo [][] someFoos = { {new Foo(00), new Foo(01),}, {new Foo(10),}, }; There are various ways to declare arrays, as the docs show. Foo [][] someFoos = new Foo [19] [17]; So you declare your two-dimensional array, then cycle through the elements copying items into your array. -- Lew -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: help me urgent
After takeing two one dimensional arrays, i prepared one two dimensional array.like this way String [ ][ ] taskoutput=new String[prioritynamearray.length][taskvaluesarray.length]; then Loop is rotating like this way, for (int s = 0; s prioritynamearray.length; s++) { for (int t = 0; t taskvaluesarray.length; t++) { taskoutput[s][t]=here how can i add above two values into 2d arrays. } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: help me urgent
sree wrote: After takeing two one dimensional arrays, i [sic] prepared one two dimensional array.like this way String [ ][ ] taskoutput=new String[prioritynamearray.length][taskvaluesarray.length]; Please follow the Java naming conventions. It will benefit you, too. Also, array (or variant) in a variable name is generally not useful. Variables usually should not be named for their type. then Loop is rotating like this way, for (int s = 0; s prioritynamearray.length; s++) { Watch your crazy indentation, please. DO NOT USE TAB CHARACTERS TO INDENT USENET POSTS! for (int t = 0; t taskvaluesarray.length; t++) { taskoutput[s][t]=here how can i add above two values into 2d arrays. What do you want here? You have not told us. You are, in effect, defining a transformation from the cross between the value sets represented by (I'll rename your variables) 'priorities' and 'tasks'. Let me draw it: \ priorities | [0] | [1] | [2] | ... tasks |--- ---|--- ---|--- ---| ... [0] | ?| ? | ? | ... --- ---|--- ---|--- ---|--- ---| ... [1] | ?| ? | ? | ... --- ---|--- ---|--- ---|--- ---| ... [2] | ?| ? | ? | ... --- ---|--- ---|--- ---|--- ---| ... [3] | ?| ? | ? | ... --- ---|--- ---|--- ---|--- ---| ... You will need 'priorities.length' times 'tasks.length' values to fill in those question-marked matrix entries. What goes there? Please tell us. Foo results = new Foo [tasks.length] [priorities.length]; for (int tx = 0; tx tasks.length; ++tx) { for (int px = 0; ix priorities.length; ++px) { Task task = tasks[tx]; Priority priority = priorities[px]; results [px][tx] = whatDoYouWantHerePleaseTellUs(task, priority); } } You need to tell us what you want in that box. Obviously it's a value that depends on the two indexing values. You likely would want to factor that out as a method on the two arguments as I showed here. So what do you want in that box? -- Lew -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: help me urgent
Lew wrote: Foo results = new Foo [tasks.length] [priorities.length]; for (int tx = 0; tx tasks.length; ++tx) { for (int px = 0; ix priorities.length; ++px) { Task task = tasks[tx]; Priority priority = priorities[px]; results [px][tx] = whatDoYouWantHerePleaseTellUs(task, priority); Oops. '[tx][px]' . I got it backwards. } } You need to tell us what you want in that box. Obviously it's a value that depends on the two indexing values. You likely would want to factor that out as a method on the two arguments as I showed here. So what do you want in that box? -- Lew -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en