Results 1 to 2 of 2

Thread: Array output

  1. #1
    lowziqian is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Array output

    edit: sorry i solved it. thx
    Last edited by lowziqian; 12-01-2011 at 09:11 AM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Array output

    As you scan the input update a counter so that you know how much "good" data has been entered. Use this count when you want to output or manipulate the data.

    -----

    Don't create a new instance of Scanner each time around a for loop. The for loop "for(int i=0;i;i++) {" won't compile.

    In general, don't rush into code. Think about *how* you will read/store/output the data and on that basis write the code. If you think in terms of "how would I rather than the computer..." then the idea of keeping a counter appears quite naturally, and the idea of using a new pair of eyes/brain to scan the input for each new element seems unnatural.

Similar Threads

  1. help! shapes output and array issues!
    By japgoth in forum New To Java
    Replies: 2
    Last Post: 01-25-2011, 10:49 PM
  2. problem with output from Array
    By nellyman in forum New To Java
    Replies: 5
    Last Post: 01-25-2011, 06:41 PM
  3. Help with Array output Needed!
    By 2potatocakes in forum New To Java
    Replies: 2
    Last Post: 03-07-2009, 07:36 PM
  4. output from an array
    By @eddie.com in forum New To Java
    Replies: 5
    Last Post: 08-15-2008, 09:26 AM
  5. JSP to output Java String Array
    By irenavassilia in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-31-2008, 05:11 PM

Posting Permissions

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