I am trying to figure out how to write an application for which I can create instances of a class(object) during the runtime of the application.
Sorry if this is a simple thing but i am still very new to OO and having trouble grasping this specific bit.
Below is some of the code that i would be using.
public class Task
{
private String tskname;
public task(String inTskName)
{
tskname = inTskName;
}
}
In another class I would have my main
public class Application
{
public static void main(String[] args)
{
}
}
So I understand that if i wanted to create an instance (knowing that it needed to be particular quantity or particular information, i would put the following in my main and then continue on with the rest of the code.
Task task1 = new Task();
I want to be able to create tasks while the application is running. how can I do this? I don't know how many tasks there will be. How do i allow for unlimited tasks? Would using an array as my variable in main be the correct way of handling this?
It seems like you just want a way of storing the tasks? In that case just use a
List