© Doug Winnie 2021
D. WinnieEssential Java for AP CompScihttps://doi.org/10.1007/978-1-4842-6183-5_13

13. Comments and Whitespace

Doug Winnie1  
(1)
Mission Hills, KS, USA
 

Psst.

Wanna make a comment on something?

It’s pretty easy.

Start it with a double slash, //, and anything after that is ignored by the compiler, and you can write whatever you want.

Oh?

You want to say more?

Well, then start your novel with a slash asterisk, /*, and then end it with an asterisk slash, */.
// Single line comment
/* Multi-line
   comment
*/
Listing 13-1

Single-line and multiline comments

Oh, and wanna know a cool trick?

If you put a comment before a line of code or wrap it as a multiline comment, you will prevent the program from seeing the code.

That’s called commenting out your code.

Ooooh! And one more thing. There is a shortcut in IntelliJ to do that. Just select the code you want to comment out and press Control-/ or Command-/.

Neat, right?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.0.25