Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How would you add a list of "events" and "tasks" to their respective arrays?

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How would you add a list of "events" and "tasks" to their respective arrays?

    import java.util.*;


    public class Day
    {
    //Event [] events;
    //Task [] tasks;

    ArrayList<Event> events = new ArrayList<Event> ();
    ArrayList<Task> tasks = new ArrayList<Task> ();
    //tasks.add();
    //String nextEvent = "";
    //String nextTask = "";


    public Day()
    {

    }

    public String toString()
    {
    return events + " " + "\n" + tasks;
    }

    public void addEvent(Event e)
    {
    //events = e;
    }

    public void addTask(Task t)
    {
    //tasks = t;
    }
    }


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    578
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: How would you add a list of "events" and "tasks" to their respective arrays?

    Read the API docs for ArrayList, there's got to be a method to add stuff.

Similar Threads

  1. Conceptual Questions Related To "super" keyword and "constructor".
    By wikki2013 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2013, 02:14 PM
  2. "Program execution skips the "if" statement"!
    By antony1925 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 7th, 2012, 07:15 AM
  3. Replies: 3
    Last Post: December 7th, 2011, 01:03 AM
  4. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 07:35 AM