I was reading a Java article, but found no differences in the declaration and was confused over. Can anyone list me out this?
Added the Article
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Without more details as to what the question is exactly asking, I am going to answer the title of the question,
Create an
Array:Create an
ArrayList:This means, create an
ArrayListofStringandIntegerobjects. You cannot useintbecause thats a primitive data types, see the link for a list of primitive data types.Create a
Stack:Create an
Queue: (using LinkedList)Same thing as an
ArrayList, this declaration means create anQueueofStringandIntegerobjects.Update:
In response to your comment from the other given answer,
We are using
Stringonly as a pure example, but you can add any other object, but the main point is that you use an object not a primitive type. Each primitive data type has their own primitive wrapper class, see link for list of primitive data type’s wrapper class.I have posted some links to explain the difference between the two, but here are a list of primitive types
byteshortcharintlongbooleandoublefloatWhich means, you are not allowed to make an
ArrayListof integer’s like so:Also, you can use your own objects, here is my
Monsterobject I created,Here we have a
Monsterobject, but now in ourMain.javaclass we want to keep a record of all ourMonster‘s that we create, so let’s add them to anArrayList(I helped my girlfriend’s brother with a Java game, and he had to do something along those lines as well, but I hope the example was well demonstrated)