Java Basics

  • Read this code. The code and its comments are the reading.
  • You can read the code in your browser at first, but it is a good idea to also run the code for yourself, see what it does, and try experimenting with it. Please follow these instructions to get the code on your computer and play with it.
  • syntax, semantics, syntax error
  • declaration
  • comments, whitespace
  • floating point
  • conditionals, if statements
  • code formatting, style
  1. What’s the answer to the puzzle at the end? If you’re not sure, what might it be? Make a guess. What experiment could you do to test that guess?
  2. What might possibly happen if you put something inside an if statement’s condition that is just a number, like if(37)? What do you think should happen? Make a few guesses, then try it.
  3. What other little experiments can you try on this code?

What was particularly interesting, confusing, or exciting to you in this reading? Please post a response according to the reading assignment procedure.