Results 1 to 3 of 3
  1. #1
    kepler is offline Member
    Join Date
    Mar 2015
    Posts
    7
    Rep Power
    0

    Default Arrays in Java - populating

    Good afternoon,

    As a programmer - very newbie in Java, however - I must convert some Java fubction to a plain "Basic", as VB6.

    The problem I'm facing is this: Supose I have an array like

    Java Code:
    private static final int[][] Terms = {
        {193, 26, 13},
        {183, 29, 14},
        {170, 20, 11}
      }; // total 659 terms
    How do I populate the Terms array?

    Is it:

    Terms[0,0]=193;
    Terms[1,0]=26;
    Terms[2,0]=13;

    Terms[0,1]=183;
    Terms[1,1]=29;
    Terms[2,1]=14;

    Terms[0,2]=170;
    Terms[1,2]=20;
    Terms[2,2]=11;

    ?

    I'm not sure this is right...
    Is there a way to automate this process? What if we have arrays like int[][][] Terms?

    This is terrible... Is there a software tool for this?

    Kind regards,

    JKepler
    Last edited by kepler; 03-18-2015 at 05:01 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Arrays in Java - populating

    Are you asking a question about Basic syntax or Basic programming? This is a Java forum. It also looks like you have figured out how to populate the Java Terms array. The other way is to have a file of the values in appropriate order so you can use nested loops to populate the array.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Arrays in Java - populating

    If you want to print out the contents of a 2 dim array for debugging, the Arrays class's deepToString() method will format it into a String that can be printed.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. populating combo box
    By newto in forum New To Java
    Replies: 11
    Last Post: 11-25-2010, 08:53 AM
  2. Need help: Populating data
    By rahul202 in forum Java Servlet
    Replies: 0
    Last Post: 10-25-2010, 07:16 PM
  3. populating a JList
    By hariza in forum AWT / Swing
    Replies: 2
    Last Post: 09-30-2010, 03:53 AM
  4. Populating JTable with 2 arrays (Netbeans)
    By althair in forum AWT / Swing
    Replies: 3
    Last Post: 12-30-2009, 02:05 PM
  5. Populating a JTable
    By toymachiner62 in forum New To Java
    Replies: 2
    Last Post: 10-13-2009, 05:56 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
  •