Computer Science Array List

¡Supera tus tareas y exámenes ahora con Quizwiz!

The card class implements a playing card. Create an ArrayList named hand and instantiate five cards in your hand.

ArrayList <card> hand = new ArrayList<card>(); for(int i = 0; i<5; i++) hand.add(new card);

Create an ArrayList named squares and add 3 squares (there is only one variable and it is an int)

ArrayList <int> squares = new ArrayList<int>(); for(int i = 0; i < 3; i++) squares.add();

Define an arraylist

a class that manages a sequence of objects, just like an array does, but it can grow and shrink and supplies methods

determine the length of an array list named cards

cards.size();

Use a for loop to print out the information in the hand Array List

for(int i = 0; i < hand.size(); i++) syso(hand.get(i));

add Joe to an array list named names

names.add("Joe");

does .substring include the last parameter

no

get the 3rd item in an ArrayList named squares

squares.get(3);

What is the size of an array list when it is first constructed

0


Conjuntos de estudio relacionados

Financial Statements and the Closing Process

View Set

Chapter 56 Integumentary Function

View Set

367Qw/exp-Leadership in Nursing: NCLEX Quiz Review - ALL QUESTIONS

View Set

Cultural Anthropology Final Fall 2016, Marriage and Family Questions

View Set

AP Calc AB (Serrano) Chapter 5 Notes

View Set