Results 1 to 3 of 3
  1. #1
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default 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:
    Java 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?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default 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.

  3. #3
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default 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

Similar Threads

  1. Trouble! - Converting an User Input value to Array.
    By derekdelgrosso in forum New To Java
    Replies: 1
    Last Post: 02-07-2012, 05:58 PM
  2. Creating 2D array from all user input
    By peek_a_boo in forum New To Java
    Replies: 1
    Last Post: 12-08-2011, 09:16 PM
  3. Print Parts Of An Array [User Input]
    By PrimalScientist in forum New To Java
    Replies: 22
    Last Post: 08-30-2011, 12:09 PM
  4. Replies: 4
    Last Post: 03-09-2011, 06:54 AM
  5. user input array
    By localhost in forum New To Java
    Replies: 5
    Last Post: 12-30-2010, 05:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •