Results 1 to 2 of 2
  1. #1
    sims34 is offline Member
    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Default How to print array from user input?

    I'm working on this problem but I can't get the information that the user enters to print in the array, the only thing that prints is "done", I know if probably something simple but I can't figure it out. Here is what i have so far:

    Java Code:
    public static void main(String[] args) {
    String[][] inputData = new String[10][2];
    
    Scanner input = new Scanner(System.in);
    
    String word = "";
    
    while(true){
    
    System.out.println("Enter your data: ");
    word = input.next();
    
    
    
    if(word.equalsIgnoreCase("done")){
    
    System.out.println("Done, BYE!");
    break;
    
    }
    
    
    }
    
    System.out.println("This is the array");
    
    for(int i = 0; i < inputData.length; i++){
    
    
    for(int j = 0; j < inputData[i].length; j++){
    
    inputData[i][j] = word
    System.out.print(inputData[i][j]); 
    
    }
    Any help would be greatly appreciated.
    Last edited by sims34; 01-29-2013 at 05:32 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: How to print array from user input?

    Follow the link posted in this response in your last thread: Assign data enter by user to a 2D Array

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to store user input into an array
    By codyjava in forum New To Java
    Replies: 11
    Last Post: 12-02-2012, 04:08 AM
  2. Creating 2D array from all user input
    By peek_a_boo in forum New To Java
    Replies: 1
    Last Post: 12-08-2011, 08:16 PM
  3. Print Parts Of An Array [User Input]
    By PrimalScientist in forum New To Java
    Replies: 22
    Last Post: 08-30-2011, 11:09 AM
  4. user input array
    By localhost in forum New To Java
    Replies: 5
    Last Post: 12-30-2010, 04:00 AM
  5. Replies: 2
    Last Post: 12-02-2010, 04:18 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
  •