LOOP, ARRAY, AND METHOD

    Cards (25)

    • When there are some actions that are
      done over and over again, looping
      statements can be used to ease the
      process.
      • This loop goes through a condition block of code with the reserved keyword while.
      • When the condition is TRUE, it executes the given code inside of its brackets. The loop continues to execute the code when the condition returns TRUE.
      while Loop
      • This looping statement is a variant of the while loop.
      • Where it executes first a statement block, and then the condition will be evaluated.
      do-while Looping
    • Allows set of instructions to be performed until a certain condition is reached
      for Loop
    • If this statement is encountered inside any looping constructs, the rest of
      the statement block will be skipped, and
      the statement following the statement
      block will be executed.
      break
      • This statement is used only for looping constructs such as for, do-while, and while loops.
      • It allows you to stop the loop before it completes it and reset it to go back to the beginning and start for a new iteration.
      continue
    • This uses multiple loops, and it exists inside the body of another loop.
      nested loop
    • In a ____ loop, a special value called sentinel is used to stop the
      loop.
      sentinel-controlled
    • A ____ statement is a way to exit out of a loop. It differs from a normal break statement in a way that this statement terminates a specific loop while a normal break statement terminates the whole loop.
      Labeled Break
    • A ____ statement has the same concept as Labeled Break statement, but instead of terminating a specific loop, this statement skips a specific loop.
      Labeled Continue
    • Arrays in JAVA are ____ that allow you to group common data types together.
      data structures
    • Arrays in JAVA are ____ that are declared and have a memory address as an actual value.
      objects
    • Arrays in JAVA are ____, where once the size of the array is declared, it can no longer ba changed.
      immutable
    • Arrays in JAVA are ____, where the size is assigned only in runtime and not a compile time.
      dynamic
    • A one-dimensional array is a collection of elements of the same type arranged in a linear sequence.
    • Basically, an array is like a list. 
    • dataType[] arrayName = new dataType[arraySize];

      one-dimensional array syntax
    • SKIP THIS: for lessons only.
    • in:
      dataType[] arrayName = new dataType[arraySize];
      • Default values - Elements are initialized with default values.
      • Specified size - You can specify the size of the array when you create it.
      • Fixed-size - The size of the array can no longer be changed.
    • in:
      dataType[] arrayName = {element1, …, elementn};
      • Concise values - You can initialize the specific values of the array once you declare it.
      • Dynamic size - The size of the array will vary depending on the number of elements you provide.
    • To access an array:
      arrayName[index]
    • ____ = number of elements in array >= 0
      • Means that ____ corresponds to the number of elements inside an array, and they cannot be less than 0
      arraySize
    • A multidimensional array organizes data in more than one dimension; can also be thought of as an array of arrays.
    • A two-dimensional array organizes data in two dimensions.
    • While a one-dimensional array is like
      a list, a two-dimensional array is like a table or grid.
    See similar decks