Results 1 to 7 of 7

Thread: Array Question

  1. #1
    mamba24 is offline Member
    Join Date
    Jun 2012
    Posts
    4
    Rep Power
    0

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,001
    Rep Power
    10

    Default Re: Array Question

    What have you tried? Where are you stuck?

    I recommend googling something like "java arrays" to get started.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    mamba24 is offline Member
    Join Date
    Jun 2012
    Posts
    4
    Rep Power
    0

    Default Re: Array Question

    Quote Originally Posted by KevinWorkman View Post
    What have you tried? Where are you stuck?

    I recommend googling something like "java arrays" to get started.
    I have some basic knowledge on arrays. I'm trying to create something like a contact list. The program should be interactive. So basically I am getting caught up with taking a file already in existence and putting the names from that file into an array.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,001
    Rep Power
    10

    Default Re: Array Question

    Quote Originally Posted by mamba24 View Post
    I have some basic knowledge on arrays. I'm trying to create something like a contact list. The program should be interactive. So basically I am getting caught up with taking a file already in existence and putting the names from that file into an array.
    And which part of that is giving you trouble? Reading in a file? Converting a line of data into an Object? Adding Objects to an array?

    I'd recommend googling something like "java file io" to get started.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: Array Question

    The lines that you read in from the file are Strings, so just populate the array with those strings.

  6. #6
    mamba24 is offline Member
    Join Date
    Jun 2012
    Posts
    4
    Rep Power
    0

    Default Re: Array Question

    public static void nameMenu1(Scanner sc) throws FileNotFoundException{

    File file = new File("names.txt");
    Scanner inputFile = new Scanner(file);

    Scanner[] madeArray = new Scanner[] {inputFile};

    System.out.print(madeArray);

    }

    This all compiles, but gives me an error when I try to run it.

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,001
    Rep Power
    10

    Default Re: Array Question

    What is the error? And what do you expect it to do? Why are you making an array of Scanners?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Question about a 2d array example
    By silverglade in forum New To Java
    Replies: 8
    Last Post: 06-07-2011, 12:56 AM
  2. Array question..
    By gerarda in forum New To Java
    Replies: 14
    Last Post: 03-02-2011, 02:42 AM
  3. Array question
    By TaxpayersMoney in forum New To Java
    Replies: 5
    Last Post: 06-11-2010, 02:41 AM
  4. Array Question
    By sc001 in forum New To Java
    Replies: 1
    Last Post: 02-14-2010, 05:57 AM
  5. array question
    By dazednconfused in forum New To Java
    Replies: 4
    Last Post: 09-15-2009, 06:44 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
  •