Thread: Java-Beginer
View Single Post
Old 04-28-2010   #3
JouJ
Registered Member
 
JouJ's Avatar
 
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
Default

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 .......
JouJ is offline   Reply With Quote