How do you:
1. Initialize (create) an Array.
2. Push a String value into it.
3. Push another String value into it.
4. Dump it to get its contents.
How do you: 1. Initialize (create) an Array. 2. Push a String value into
Share
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.
Arrays in Java are a fixed size, determined when you create them. As such, they have no push methods.
It sounds like you want a
Listinstead, most likely anArrayList<String>. Lists have anaddfunction for adding new elements.The Java Collections trail has more information about the various types of collections (List, Set, and Map).
Lists and Sets work with Java’s for each operator: