|
|
|||||||
| Computers & Information Technologies « Everything related to computers and internet. » |
![]() |
|
|
Share | Thread Tools | Search this Thread |
|
|
#1 |
|
Registered Member
Last Online: 05-15-2012
Join Date: Sep 2006
Posts: 530
Thanks: 9
Thanked 41 Times in 34 Posts
Groans: 0
Groaned at 1 Time in 1 Post
|
(a) Create a new class Test_Array that has the following 3 class methods:
(i) fillArray() takes an integer array as an argument. It allows user to fill-up values in this array by using a for loop and a series of dialog boxes. public static void fillArray(int[] value) { String valueInput; String length; length = OUDialog.request("How much Value to store?", "1"); value = new int[Integer.parseInt(length)]; for(int i=0; i<value.length; i++) { valueInput=OUDialog.request("Please insert an integer value", "0"); value[i]=Integer.parseInt(valueInput); } } int[] a; Test_Array.fillArray(a); when executing the array a is stayed null and is not affected..... what is mistake? pleeeeeeeeeeeeeeeeeeeeeeease help me ![]()
__________________
ALEXANDER Al-Kabeer Gonna rule you all...
|
|
|
|
|
|
#2 |
|
Beyond the Code
Last Online: 06-15-2014
Join Date: Sep 2008
Posts: 2,993
Thanks: 2,214
Thanked 3,426 Times in 1,499 Posts
Groans: 57
Groaned at 69 Times in 52 Posts
|
Grammar Nazis, Do your job.
__________________
Whatever you do, do it for the Lulz. |
|
|
|
|
|
#3 |
|
Registered Member
Last Online: 04-17-2018
Join Date: Jul 2009
Posts: 15
Thanks: 127
Thanked 10 Times in 6 Posts
Groans: 2
Groaned at 0 Times in 0 Posts
|
hey 7anzala I'm new to the java language but i tried to see what's the problem in this project I am not familiar with the command you are using for the dialog box(which i think is your problem) but here is my way to wright this project :
The class : import javax.swing.JOptionPane; public class Test_Array { public static void fillArray(int[] value){ String valueInput; String length; length = JOptionPane.showInputDialog("how much value to store ?"); value = new int[Integer.parseInt(length)]; for(int i=0; i<value.length; i++) { valueInput = JOptionPane.showInputDialog("please insert an integer value"); value[i]=Integer.parseInt(valueInput); } for (int i=0;i<value.length;i++){ System.out.println("value ["+i+"] = "+value[i]); } } } The main class : public class Main { public static void main(String[] args) { int[] a = null ; Test_Array.fillArray(a); } } PS: the last for loop is to display the affected values in the array. good luck hope i helped you |
|
|
|
|
|
#4 |
|
Registered Member
Last Online: 05-15-2012
Join Date: Sep 2006
Posts: 530
Thanks: 9
Thanked 41 Times in 34 Posts
Groans: 0
Groaned at 1 Time in 1 Post
|
mmm yes i made a difference
10x
__________________
ALEXANDER Al-Kabeer Gonna rule you all...
|
|
|
|
![]() |
|
| Tags |
| javabeginer |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|