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

Pitfall


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

  • Example: "5 + 2 is " + (5 + 2);

Pitfall


nextLine() Trap
PitfallnextLine() gets skipped when placed after nextInt() , nextDouble(), or nextLong().
SolutionAdd a throwaway nextLine() before the "real" nextLine().
ExplanationThe upcoming lesson on Delimiters will explain why this happens.

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.

Associated Course: The Complete Java Development Bootcamp
Related Course: The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary
4.7
43 students
5

91%
4

2%
3

0%
2

0%
1

7%
Written Reviews
There are no written reviews yet.