Results 1 to 3 of 3
  1. #1
    xkross is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default returning a value from an arraylist

    How can you return a value from an arraylist that contains class objects and the class object contains both string and numeric variables?

    need the numeric data to do further calculations with.

    public class Student
    {
    private String name;
    private double Stbalance;


    // -------------------------------------------------------
    // Create a new item with the given attributes.
    // -------------------------------------------------------
    public Student (String ssName, double sbalance)
    {
    name = sName;
    Stbalance = sbalance;
    }
    }


    ArrayList Theclass = new ArrayList();

    pupil = new Student(studentname,studentbalance);

    Theclass.add(pupil);


    How can is use the get method to return the balance into another variable?

  2. #2
    xkross is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default

    Ok... i figured out the answer by reading the post displayed below.

    Java Project Trouble: Searching one ArrayList with another

    got help on line 14 of the post which reads.

    Integer firstTemp = (Integer) first.get(i);

  3. #3
    fireball2008 is offline Member
    Join Date
    Apr 2008
    Posts
    28
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 04-21-2008, 11:43 AM
  2. Replies: 0
    Last Post: 03-11-2008, 04:55 PM
  3. Returning a string (Partly Bold)
    By TampaTechGuy in forum New To Java
    Replies: 3
    Last Post: 02-03-2008, 09:54 AM
  4. JNI - passing and returning parameters by value
    By java_to_c in forum New To Java
    Replies: 0
    Last Post: 01-31-2008, 08:49 PM
  5. Replies: 4
    Last Post: 07-31-2007, 05:19 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
  •