Results 1 to 2 of 2
  1. #1
    shazakala is offline Member
    Join Date
    Mar 2011
    Posts
    19
    Rep Power
    0

    Default taking something from an array.

    I have muliple classes and one of them is requesting that I take something from an array and print it out.
    Java Code:
    e.addPerson(p1);
    I think I have to do something like

    public addPerson(){
    return people;
    }

    but thats not requesting p1 specifically from the array. any ideas?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You really haven't given much information. What is e, p1, people?

    My guess is this: You can get a single element out of an array with the subscript operator([]).

    Java Code:
    int[] x = new int[] {1, 2, 3, 4, 5, 6 };
    System.out.println(x[0]); //prints 1

Similar Threads

  1. Double not taking a point (eg 10.12)
    By N00Bie in forum New To Java
    Replies: 7
    Last Post: 02-11-2011, 11:56 PM
  2. taking number value without sign
    By sara12345 in forum New To Java
    Replies: 5
    Last Post: 06-01-2010, 10:03 AM
  3. Taking Java In School Need Help
    By xEuPhOrIcSx in forum New To Java
    Replies: 7
    Last Post: 02-04-2008, 08:02 AM
  4. Taking passwords on the console
    By eva in forum Advanced Java
    Replies: 2
    Last Post: 12-19-2007, 09:28 AM
  5. Taking input from console
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-05-2007, 04:47 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
  •