Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 1.33 KB

File metadata and controls

32 lines (24 loc) · 1.33 KB

Chapter 2: Java Fundamentals Notes

Reading a Character :

The Scanner class does not have a method for reading a single character, however. Using Scanner class's nextLine method to read a string from the keyboard, and then use String class's charAt method to extract the first character of the string will solve the problem.

Scanner method's annoying nextLine problem:

Will update later...

Common Errors to Avoid

  • Mismatched braces, quotation marks, or parentheses.
  • Misspelling key words.
  • Using capital letters in key word.
  • Using key word as variable name.
  • Using inconsistent spelling of variable names.
  • using inconsistent case of letters in variable names.
  • Inserting a space in a variable name.
  • Forgetting the semicolon at the end of the statement.
  • Assigning a double literal to a float variable.
  • Using commas or other currency symbols in numeric literals.
  • Unintentionally performing integer division.
  • Forgetting to group parts of a mathematical expression.
  • Inserting a space in a combined assignment operator.
  • Using a variable to receive the result of calculation when the variable's data type is incompatible with the data type of the result.
  • Incorrectly terminating a multi*line comment or a documentation comment
  • Forgetting to use the correct import statement in a program that uses X library.