Java Bootcamp – Workbooks and Challenges
)}

Cheat Sheet

This cheat sheet contains important takeaways that lead up to section two.

1. Getting Started


  • class: contains all of your code.

  • main(): entry point of your app.

  • javac <file-name>.java: compiles your code.

  • java <file-name>: runs the compiled code.

2. Variables


Data types

There are 6 main data types (we didn't cover boolean yet).

long can store very big numbers. But, int is faster and takes less memory.

Operators

Scanner

nextLine(): scans for a String value.

nextDouble(): scans for a double value.

nextLong(): scans for a long value.

nextInt(): scans for an int value.

Coding Pitfalls


  • Put math operations in brackets if you wish to embed them inside a String.

    • "Example String " + (10 - 2) + " Example String " ;
  • Trap: Putting nextLine() ahead of nextInt(), nextDouble(), nextLong(), or next().

    • Solution: add a throwaway nextLine() before the real nextLine().

**The reason this happens will be covered in the lesson: Delimiters.

Good coding habits


  • class: CamelCase.

  • variable: lowerCamelCase.

Tips and tricks


Terminal

  • Use the up key to run previous terminal commands.

  • Write clear to clear the terminal output.

  • Press the tab key for auto-complete.

Escape characters

  • \n adds a new line of space.

  • \t adds a new tab of space.

Shortcut keys

  • Use CMD/Ctrl+/ to comment a highlighted piece of code.

Feedback Summary
4.8
39 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.