Pass User Input into an Array
I am asking for user input and I want to pass that UserInput into an array. The code I am using is:
Code:
enteredHoursWorked = JOptionPane.showInputDialog("Enter hours worked");
myArray[] = enteredHoursWorked;
I get numerous compile errors:
error not a statement
error ";" expected
How would I pass user input into an array?
Re: Pass User Input into an Array
See the API for JOptionPane - the method you are using returns a String. We have not idea what you are trying to do, what type of array you have created, if you want the String to be part of the array or you wish to parse the String, but based upon what you posted you cannot assign an array to a String.
Re: Pass User Input into an Array
I need to to declare an array of 2 objects to call my methods.
I will look into the API for JOptionPane and see if I can find my answer there