Results 1 to 2 of 2
  1. #1
    noviceJava is offline Member
    Join Date
    Apr 2012
    Posts
    16
    Rep Power
    0

    Default accessing many elements in an array

    So I have this String[] that contains the following, but this data is from a larger file that I had to split
    10 20 12
    Some code below
    Java Code:
        String[] Contents = line.split("[A-Z]");
        int parametersread = 0;
        for (String liness : Contents) {
            Object[] newlines = new Object[Contents.length];
             System.out.println("line 115a - rho theat state ==" + liness);
              if (parametersread == 2) {
                   for (int a = 0 ; a < Contents.length ; a++) {
                        System.out.println("a===" + a);
              System.out.println("Line 133 - newlines = " + newlines[3]);
              
            }
    So when I print newlines[3] = 10 20 12
    But now I what to break out this array to access the 3 elements in that array
    So for example newlines[3].get the first element 10 and store that into variable Start
    Then newlines[3].get 2nd element 20 and store that into variable Stop
    Then newlines[3].get 3rd element 12 and store that into variable Go
    So Iím trying to get the 3 elements out of newlines[3]?

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

    Default Re: accessing many elements in an array

    What's wrong with splitting them again?

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

Similar Threads

  1. Accessing Elements of a Reflected ArrayList
    By FALL3N1 in forum Advanced Java
    Replies: 3
    Last Post: 03-22-2012, 09:49 AM
  2. Replies: 3
    Last Post: 11-25-2011, 12:38 AM
  3. keep the first N elements of an array only
    By aneuryzma in forum New To Java
    Replies: 13
    Last Post: 03-27-2011, 04:03 PM
  4. Replies: 5
    Last Post: 01-18-2010, 07:00 AM
  5. Help with array of elements
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 05:33 PM

Tags for this Thread

Posting Permissions

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