Skip to content

Lesson 2 (ControlFlow & Collections)

Courtney Frey edited this page Apr 15, 2022 · 3 revisions

Lesson 2: Control Flow and Collections

In the prep work for this lesson, the students learned

  1. The Java syntax for conditionals and loops:
    1. if/, else, if/else
    2. switch statements
    3. for, while, and do...while
  2. How to use the Array, ArrayList, and HashMap collections.

Announcements

  1. Check with your class Candidate Engagement Manager for any other announcements.

For Part-Time Students:

  1. Remind students that Graded Assignment #1 is due soon! They should be able to complete the project after today's class.

For Full-Time Students:

  • Welcome to Day 2!
  • Lesson 2
  • Leave time in afternoon to introduce Assignment 1
  • Graded Assignment #1 is open! With each of the graded assignments in this unit, the key is to read through everything carefully and start on what you can do as soon as possible. In class, read through the instructions with your students and highlight what they are capable of doing after this class.
  • Assignment 1 work day scheduled for Days, 4, 6 & 7

Large Group Time (Instructor)

Lesson 2 Topics That Require Careful Attention

  1. Encouragement: Point out that learning a second coding language is usually easier than learning the first. The students already know how to use loops and conditionals, so applying them in Java is just a matter of recognizing the different syntax.
    1. Ask the class to give some examples of similarities or differences for conditionals and loops in Java vs. other coding languages.
  2. The "fallthrough" aspect of switch statements is not always obvious and should be reviewed. However, do not sink too much time into this, since the students will use if/else statements much more often than switch.
  3. Ask the students to explain the difference between while and do...while loops.
  4. Review how to use break and continue statements within loops.
  5. Review for...each loops in the context of Array and ArrayList collections. Note how the syntax changes when applied to HashMaps.
  6. As much as possible, live-code examples for ArrayLists and HashMaps, including how to use the most common methods.

Lesson 2 Studio (TF Notes)

  1. With your group, discuss the "Some Items to Ponder Before Starting" section of the studio instructions.
  2. Remember to check in with EVERY student during the studio time.
    1. Ask them detailed questions about studio 1 if they did not finish it before the end of the last class.
    2. As they code studio 2, ask them to explain what different portions of their code does.
  3. Common mistakes:
    1. Not properly setting up the main method.
    2. Forgetting to import the necessary classes (e.g. HashMap).
    3. Even though HashMaps are the better option, many students will try to use Arrays or ArrayLists because they see them as being easier. While the students could make these collections work, be prepared to nudge them in a different direction if they get stuck.
  4. Be sure to do a visual check of your students' code.
  5. For the students who finish early, ask guided questions to encourage them to try one or more of the bonus tasks (e.g. "How could you modify your code to count 'a' and 'A' as the same letter?").
  6. Remind your students to push their work up to GitHub when they finish the studio.
Clone this wiki locally