Execute commands in ArrayList
Normally, I will execute the followings:
System.out.println("Title DVD 1: " + dvd1.getTitle());
System.out.println("Title DVD 2: " + dvd2.getTitle());
Then I will get the titles of DVD 1 and DVD 2. If I want to print 100 titles of DVDs, obviously I need a lot of
System.out.println.
I managed to get these System.out.println in an ArrayList as follows:
ArrayList<String> displayDVDList = new ArrayList<String>();
for ( int i = 0; i <= 22; i++)
displayDVDList.add("System.out.println("Title DVD " + i + " : "
+ dvd" + i + ".getTitle());");
System.out.println(displayDVDList.get(i) + " ");
However, I cannot execute those System.out.println to display the titles. Thus, how to execute a value of ArrayList which happens to be System.out.println command?
Any help is much appreciated. Thank you.
java arraylist
add a comment |
Normally, I will execute the followings:
System.out.println("Title DVD 1: " + dvd1.getTitle());
System.out.println("Title DVD 2: " + dvd2.getTitle());
Then I will get the titles of DVD 1 and DVD 2. If I want to print 100 titles of DVDs, obviously I need a lot of
System.out.println.
I managed to get these System.out.println in an ArrayList as follows:
ArrayList<String> displayDVDList = new ArrayList<String>();
for ( int i = 0; i <= 22; i++)
displayDVDList.add("System.out.println("Title DVD " + i + " : "
+ dvd" + i + ".getTitle());");
System.out.println(displayDVDList.get(i) + " ");
However, I cannot execute those System.out.println to display the titles. Thus, how to execute a value of ArrayList which happens to be System.out.println command?
Any help is much appreciated. Thank you.
java arraylist
1
OK, for starters, you can't "execute an ArrayList". What are you actually trying to (without reference to how you're trying to do it)?
– Bohemian♦
Nov 14 '18 at 0:20
If you addObjects
to your ArrayList, then after doing aget
you canact
on theObject
e.g.ArrayList<DVD> displayDVDList = new ArrayList<DVD>();
– Scary Wombat
Nov 14 '18 at 0:21
@Scary Wombat I don't quite understand what you meant by "adding Objects". How to do that?
– smalltownstory
Nov 14 '18 at 0:27
I was trying to have a lot of these: System.out.println("Title DVD 0 : " + dvd0.getTitle()); System.out.println("Title DVD 1 : " + dvd1.getTitle()); System.out.println("Title DVD 2 : " + dvd2.getTitle()); System.out.println("Title DVD 3 : " + dvd3.getTitle()); System.out.println("Title DVD 4 : " + dvd4.getTitle());
– smalltownstory
Nov 14 '18 at 0:28
add a comment |
Normally, I will execute the followings:
System.out.println("Title DVD 1: " + dvd1.getTitle());
System.out.println("Title DVD 2: " + dvd2.getTitle());
Then I will get the titles of DVD 1 and DVD 2. If I want to print 100 titles of DVDs, obviously I need a lot of
System.out.println.
I managed to get these System.out.println in an ArrayList as follows:
ArrayList<String> displayDVDList = new ArrayList<String>();
for ( int i = 0; i <= 22; i++)
displayDVDList.add("System.out.println("Title DVD " + i + " : "
+ dvd" + i + ".getTitle());");
System.out.println(displayDVDList.get(i) + " ");
However, I cannot execute those System.out.println to display the titles. Thus, how to execute a value of ArrayList which happens to be System.out.println command?
Any help is much appreciated. Thank you.
java arraylist
Normally, I will execute the followings:
System.out.println("Title DVD 1: " + dvd1.getTitle());
System.out.println("Title DVD 2: " + dvd2.getTitle());
Then I will get the titles of DVD 1 and DVD 2. If I want to print 100 titles of DVDs, obviously I need a lot of
System.out.println.
I managed to get these System.out.println in an ArrayList as follows:
ArrayList<String> displayDVDList = new ArrayList<String>();
for ( int i = 0; i <= 22; i++)
displayDVDList.add("System.out.println("Title DVD " + i + " : "
+ dvd" + i + ".getTitle());");
System.out.println(displayDVDList.get(i) + " ");
However, I cannot execute those System.out.println to display the titles. Thus, how to execute a value of ArrayList which happens to be System.out.println command?
Any help is much appreciated. Thank you.
java arraylist
java arraylist
asked Nov 14 '18 at 0:18
smalltownstorysmalltownstory
11
11
1
OK, for starters, you can't "execute an ArrayList". What are you actually trying to (without reference to how you're trying to do it)?
– Bohemian♦
Nov 14 '18 at 0:20
If you addObjects
to your ArrayList, then after doing aget
you canact
on theObject
e.g.ArrayList<DVD> displayDVDList = new ArrayList<DVD>();
– Scary Wombat
Nov 14 '18 at 0:21
@Scary Wombat I don't quite understand what you meant by "adding Objects". How to do that?
– smalltownstory
Nov 14 '18 at 0:27
I was trying to have a lot of these: System.out.println("Title DVD 0 : " + dvd0.getTitle()); System.out.println("Title DVD 1 : " + dvd1.getTitle()); System.out.println("Title DVD 2 : " + dvd2.getTitle()); System.out.println("Title DVD 3 : " + dvd3.getTitle()); System.out.println("Title DVD 4 : " + dvd4.getTitle());
– smalltownstory
Nov 14 '18 at 0:28
add a comment |
1
OK, for starters, you can't "execute an ArrayList". What are you actually trying to (without reference to how you're trying to do it)?
– Bohemian♦
Nov 14 '18 at 0:20
If you addObjects
to your ArrayList, then after doing aget
you canact
on theObject
e.g.ArrayList<DVD> displayDVDList = new ArrayList<DVD>();
– Scary Wombat
Nov 14 '18 at 0:21
@Scary Wombat I don't quite understand what you meant by "adding Objects". How to do that?
– smalltownstory
Nov 14 '18 at 0:27
I was trying to have a lot of these: System.out.println("Title DVD 0 : " + dvd0.getTitle()); System.out.println("Title DVD 1 : " + dvd1.getTitle()); System.out.println("Title DVD 2 : " + dvd2.getTitle()); System.out.println("Title DVD 3 : " + dvd3.getTitle()); System.out.println("Title DVD 4 : " + dvd4.getTitle());
– smalltownstory
Nov 14 '18 at 0:28
1
1
OK, for starters, you can't "execute an ArrayList". What are you actually trying to (without reference to how you're trying to do it)?
– Bohemian♦
Nov 14 '18 at 0:20
OK, for starters, you can't "execute an ArrayList". What are you actually trying to (without reference to how you're trying to do it)?
– Bohemian♦
Nov 14 '18 at 0:20
If you add
Objects
to your ArrayList, then after doing a get
you can act
on the Object
e.g. ArrayList<DVD> displayDVDList = new ArrayList<DVD>();
– Scary Wombat
Nov 14 '18 at 0:21
If you add
Objects
to your ArrayList, then after doing a get
you can act
on the Object
e.g. ArrayList<DVD> displayDVDList = new ArrayList<DVD>();
– Scary Wombat
Nov 14 '18 at 0:21
@Scary Wombat I don't quite understand what you meant by "adding Objects". How to do that?
– smalltownstory
Nov 14 '18 at 0:27
@Scary Wombat I don't quite understand what you meant by "adding Objects". How to do that?
– smalltownstory
Nov 14 '18 at 0:27
I was trying to have a lot of these: System.out.println("Title DVD 0 : " + dvd0.getTitle()); System.out.println("Title DVD 1 : " + dvd1.getTitle()); System.out.println("Title DVD 2 : " + dvd2.getTitle()); System.out.println("Title DVD 3 : " + dvd3.getTitle()); System.out.println("Title DVD 4 : " + dvd4.getTitle());
– smalltownstory
Nov 14 '18 at 0:28
I was trying to have a lot of these: System.out.println("Title DVD 0 : " + dvd0.getTitle()); System.out.println("Title DVD 1 : " + dvd1.getTitle()); System.out.println("Title DVD 2 : " + dvd2.getTitle()); System.out.println("Title DVD 3 : " + dvd3.getTitle()); System.out.println("Title DVD 4 : " + dvd4.getTitle());
– smalltownstory
Nov 14 '18 at 0:28
add a comment |
3 Answers
3
active
oldest
votes
Assuming the type of dvd1
and dvd2
is a class Dvd
with the getTitle()
method, your code could be something like the following, where the elements of the list are not String
values, but Dvd
objects.
// Build list of DVDs
Random random = new Random();
ArrayList<Dvd> displayDVDList = new ArrayList<>();
for (int i = 0; i <= 22; i++)
String dvdTitle = "DVD #" + (random.nextInt(1000) + 1);
displayDVDList.add(new Dvd(dvdTitle));
// Print list of DVDs
for (int i = 0; i < displayDVDList.size(); i++)
Dvd dvd = displayDVDList.get(i);
System.out.println("Title DVD " + (i + 1) + ": " + dvd.getTitle());
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
@smalltownstory Maybe what would be even nicer would be to have theDvd
themselves have aprint
ortoString
method
– Scary Wombat
Nov 14 '18 at 0:55
add a comment |
Every answer is helpful and I am adding to it .First Thing to
understand is , u want some property of your object to be printed. Use
toString() method from object class , as it it created specifically
for it . use arrayList.toString() and override toString() in your
class.
class Person1
String name ;
String state;
public Person1(String name, String state)
super();
this.name = name;
this.state = state;
public Person1()
super();
@Override
public String toString()
return "Person [name=" + name + ", state=" + state + "]";
public static void main(String args)
Person nitin = new Person("nitin", "delhi");
Person chandan = new Person("chandan", "delhi");
Person anshu = new Person("anshu", "bihar");
Person rahul = new Person("rahul", "bihar");
Person amar = new Person("nitin", "UP");
List<Person> peoples = Arrays.asList(nitin,chandan, anshu, rahul,amar);
System.out.println(peoples);
add a comment |
You could load everything first and then print with the System.out.println. Java 8 has a way to run using stream. For example:
ArrayList<String> displayDVDList = new ArrayList<String>();
displayDVDList.add("Title 1");
displayDVDList.add("Title 2");
displayDVDList.add("Title 3");
displayDVDList.add("Title 4");
displayDVDList.add("Title 5");
displayDVDList.forEach(System.out::println);
I hope it helps you !
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291373%2fexecute-commands-in-arraylist%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming the type of dvd1
and dvd2
is a class Dvd
with the getTitle()
method, your code could be something like the following, where the elements of the list are not String
values, but Dvd
objects.
// Build list of DVDs
Random random = new Random();
ArrayList<Dvd> displayDVDList = new ArrayList<>();
for (int i = 0; i <= 22; i++)
String dvdTitle = "DVD #" + (random.nextInt(1000) + 1);
displayDVDList.add(new Dvd(dvdTitle));
// Print list of DVDs
for (int i = 0; i < displayDVDList.size(); i++)
Dvd dvd = displayDVDList.get(i);
System.out.println("Title DVD " + (i + 1) + ": " + dvd.getTitle());
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
@smalltownstory Maybe what would be even nicer would be to have theDvd
themselves have aprint
ortoString
method
– Scary Wombat
Nov 14 '18 at 0:55
add a comment |
Assuming the type of dvd1
and dvd2
is a class Dvd
with the getTitle()
method, your code could be something like the following, where the elements of the list are not String
values, but Dvd
objects.
// Build list of DVDs
Random random = new Random();
ArrayList<Dvd> displayDVDList = new ArrayList<>();
for (int i = 0; i <= 22; i++)
String dvdTitle = "DVD #" + (random.nextInt(1000) + 1);
displayDVDList.add(new Dvd(dvdTitle));
// Print list of DVDs
for (int i = 0; i < displayDVDList.size(); i++)
Dvd dvd = displayDVDList.get(i);
System.out.println("Title DVD " + (i + 1) + ": " + dvd.getTitle());
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
@smalltownstory Maybe what would be even nicer would be to have theDvd
themselves have aprint
ortoString
method
– Scary Wombat
Nov 14 '18 at 0:55
add a comment |
Assuming the type of dvd1
and dvd2
is a class Dvd
with the getTitle()
method, your code could be something like the following, where the elements of the list are not String
values, but Dvd
objects.
// Build list of DVDs
Random random = new Random();
ArrayList<Dvd> displayDVDList = new ArrayList<>();
for (int i = 0; i <= 22; i++)
String dvdTitle = "DVD #" + (random.nextInt(1000) + 1);
displayDVDList.add(new Dvd(dvdTitle));
// Print list of DVDs
for (int i = 0; i < displayDVDList.size(); i++)
Dvd dvd = displayDVDList.get(i);
System.out.println("Title DVD " + (i + 1) + ": " + dvd.getTitle());
Assuming the type of dvd1
and dvd2
is a class Dvd
with the getTitle()
method, your code could be something like the following, where the elements of the list are not String
values, but Dvd
objects.
// Build list of DVDs
Random random = new Random();
ArrayList<Dvd> displayDVDList = new ArrayList<>();
for (int i = 0; i <= 22; i++)
String dvdTitle = "DVD #" + (random.nextInt(1000) + 1);
displayDVDList.add(new Dvd(dvdTitle));
// Print list of DVDs
for (int i = 0; i < displayDVDList.size(); i++)
Dvd dvd = displayDVDList.get(i);
System.out.println("Title DVD " + (i + 1) + ": " + dvd.getTitle());
answered Nov 14 '18 at 0:31
AndreasAndreas
76.5k463124
76.5k463124
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
@smalltownstory Maybe what would be even nicer would be to have theDvd
themselves have aprint
ortoString
method
– Scary Wombat
Nov 14 '18 at 0:55
add a comment |
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
@smalltownstory Maybe what would be even nicer would be to have theDvd
themselves have aprint
ortoString
method
– Scary Wombat
Nov 14 '18 at 0:55
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
I will have a try. Thank you for your help.
– smalltownstory
Nov 14 '18 at 0:40
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
It half works. Only now I have to think how to add all them up.
– smalltownstory
Nov 14 '18 at 0:51
@smalltownstory Maybe what would be even nicer would be to have the
Dvd
themselves have a print
or toString
method– Scary Wombat
Nov 14 '18 at 0:55
@smalltownstory Maybe what would be even nicer would be to have the
Dvd
themselves have a print
or toString
method– Scary Wombat
Nov 14 '18 at 0:55
add a comment |
Every answer is helpful and I am adding to it .First Thing to
understand is , u want some property of your object to be printed. Use
toString() method from object class , as it it created specifically
for it . use arrayList.toString() and override toString() in your
class.
class Person1
String name ;
String state;
public Person1(String name, String state)
super();
this.name = name;
this.state = state;
public Person1()
super();
@Override
public String toString()
return "Person [name=" + name + ", state=" + state + "]";
public static void main(String args)
Person nitin = new Person("nitin", "delhi");
Person chandan = new Person("chandan", "delhi");
Person anshu = new Person("anshu", "bihar");
Person rahul = new Person("rahul", "bihar");
Person amar = new Person("nitin", "UP");
List<Person> peoples = Arrays.asList(nitin,chandan, anshu, rahul,amar);
System.out.println(peoples);
add a comment |
Every answer is helpful and I am adding to it .First Thing to
understand is , u want some property of your object to be printed. Use
toString() method from object class , as it it created specifically
for it . use arrayList.toString() and override toString() in your
class.
class Person1
String name ;
String state;
public Person1(String name, String state)
super();
this.name = name;
this.state = state;
public Person1()
super();
@Override
public String toString()
return "Person [name=" + name + ", state=" + state + "]";
public static void main(String args)
Person nitin = new Person("nitin", "delhi");
Person chandan = new Person("chandan", "delhi");
Person anshu = new Person("anshu", "bihar");
Person rahul = new Person("rahul", "bihar");
Person amar = new Person("nitin", "UP");
List<Person> peoples = Arrays.asList(nitin,chandan, anshu, rahul,amar);
System.out.println(peoples);
add a comment |
Every answer is helpful and I am adding to it .First Thing to
understand is , u want some property of your object to be printed. Use
toString() method from object class , as it it created specifically
for it . use arrayList.toString() and override toString() in your
class.
class Person1
String name ;
String state;
public Person1(String name, String state)
super();
this.name = name;
this.state = state;
public Person1()
super();
@Override
public String toString()
return "Person [name=" + name + ", state=" + state + "]";
public static void main(String args)
Person nitin = new Person("nitin", "delhi");
Person chandan = new Person("chandan", "delhi");
Person anshu = new Person("anshu", "bihar");
Person rahul = new Person("rahul", "bihar");
Person amar = new Person("nitin", "UP");
List<Person> peoples = Arrays.asList(nitin,chandan, anshu, rahul,amar);
System.out.println(peoples);
Every answer is helpful and I am adding to it .First Thing to
understand is , u want some property of your object to be printed. Use
toString() method from object class , as it it created specifically
for it . use arrayList.toString() and override toString() in your
class.
class Person1
String name ;
String state;
public Person1(String name, String state)
super();
this.name = name;
this.state = state;
public Person1()
super();
@Override
public String toString()
return "Person [name=" + name + ", state=" + state + "]";
public static void main(String args)
Person nitin = new Person("nitin", "delhi");
Person chandan = new Person("chandan", "delhi");
Person anshu = new Person("anshu", "bihar");
Person rahul = new Person("rahul", "bihar");
Person amar = new Person("nitin", "UP");
List<Person> peoples = Arrays.asList(nitin,chandan, anshu, rahul,amar);
System.out.println(peoples);
edited Nov 14 '18 at 9:23
answered Nov 14 '18 at 9:18
nitin.kunal.emrnitin.kunal.emr
152
152
add a comment |
add a comment |
You could load everything first and then print with the System.out.println. Java 8 has a way to run using stream. For example:
ArrayList<String> displayDVDList = new ArrayList<String>();
displayDVDList.add("Title 1");
displayDVDList.add("Title 2");
displayDVDList.add("Title 3");
displayDVDList.add("Title 4");
displayDVDList.add("Title 5");
displayDVDList.forEach(System.out::println);
I hope it helps you !
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
add a comment |
You could load everything first and then print with the System.out.println. Java 8 has a way to run using stream. For example:
ArrayList<String> displayDVDList = new ArrayList<String>();
displayDVDList.add("Title 1");
displayDVDList.add("Title 2");
displayDVDList.add("Title 3");
displayDVDList.add("Title 4");
displayDVDList.add("Title 5");
displayDVDList.forEach(System.out::println);
I hope it helps you !
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
add a comment |
You could load everything first and then print with the System.out.println. Java 8 has a way to run using stream. For example:
ArrayList<String> displayDVDList = new ArrayList<String>();
displayDVDList.add("Title 1");
displayDVDList.add("Title 2");
displayDVDList.add("Title 3");
displayDVDList.add("Title 4");
displayDVDList.add("Title 5");
displayDVDList.forEach(System.out::println);
I hope it helps you !
You could load everything first and then print with the System.out.println. Java 8 has a way to run using stream. For example:
ArrayList<String> displayDVDList = new ArrayList<String>();
displayDVDList.add("Title 1");
displayDVDList.add("Title 2");
displayDVDList.add("Title 3");
displayDVDList.add("Title 4");
displayDVDList.add("Title 5");
displayDVDList.forEach(System.out::println);
I hope it helps you !
answered Nov 14 '18 at 0:59
Adán RodriguezAdán Rodriguez
11
11
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
add a comment |
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
Thank you. But, this is is the one that I want to avoid. We are not talking about 5 items. Perhaps, hundreds.
– smalltownstory
Nov 14 '18 at 1:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291373%2fexecute-commands-in-arraylist%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
OK, for starters, you can't "execute an ArrayList". What are you actually trying to (without reference to how you're trying to do it)?
– Bohemian♦
Nov 14 '18 at 0:20
If you add
Objects
to your ArrayList, then after doing aget
you canact
on theObject
e.g.ArrayList<DVD> displayDVDList = new ArrayList<DVD>();
– Scary Wombat
Nov 14 '18 at 0:21
@Scary Wombat I don't quite understand what you meant by "adding Objects". How to do that?
– smalltownstory
Nov 14 '18 at 0:27
I was trying to have a lot of these: System.out.println("Title DVD 0 : " + dvd0.getTitle()); System.out.println("Title DVD 1 : " + dvd1.getTitle()); System.out.println("Title DVD 2 : " + dvd2.getTitle()); System.out.println("Title DVD 3 : " + dvd3.getTitle()); System.out.println("Title DVD 4 : " + dvd4.getTitle());
– smalltownstory
Nov 14 '18 at 0:28