powerpoint 6.txt

Card Set Information

Author:
dimeng
ID:
299155
Filename:
powerpoint 6.txt
Updated:
2015-03-25 10:46:15
Tags:
diane cs140
Folders:
diane,cs140
Description:
diane cs140 powerpoint 6
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user dimeng on FreezingBlue Flashcards. What would you like to do?


  1. What is an array?
    An array is a collection of variables of the same type (primitive or class type).
  2. What is a good usage for an array?
    To store a list of values - all of the same type.
  3. How do you declare an array?
    • type[] name = new type[size];
    • type could be int, double, String, etc.
  4. Once an array is created, its size is _________.
    fixed
  5. How do you reference the ith element of an array int numbers = new int[20];
    numbers[i]
  6. What is the index of the first position in an array?
    0
  7. How can you find the length of an array?
    arrayName.length()
  8. What formula will always give you the last index position in an array?
    lastPosition = arrayName.length - 1
  9. How could you get the value at the last position in any array?
    arrayName[arrayName.length - 1]
  10. How could you get the value at the first position in any array?
    arrayName[0]
  11. What is the syntax for initializing an array with a list of values?
    int[] arrayName = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
  12. How could you create an array with 16 elements that starts with 1 and each position holds a value that is the last value + 1?
    • int[] numbers = new int [16];
    • for (int i=0; i<17; i++)
    • numbers[i] = i+1;
  13. Review example slides p.8-9.
  14. Should array names be singular or plural?
    singular
  15. Name three basic things you can do with arrays.
    • Assign an individual value to one place
    • Read an individual value from one place
    • Read the length of the array
  16. Can you assign values to multiple places in an array at once?
    No
  17. Can you perform a numeric operation (like addition or multiplication) on an array?
    No
  18. Is this how you compare two arrays: if (a[] == b[]) ...?
    • No. You first compare the length then each element in the array.
    • Also, you can use the .equals method.
  19. Can you assign the values of one array to another array like this: a[] = b[];?
    no

What would you like to do?

Home > Flashcards > Print Preview