CodeGym /Courses /New Java Syntax /Introducing Kim

Introducing Kim

New Java Syntax
Level 1 , Lesson 6
Available

A lecture snippet with a mentor as part of the Codegym University course. Sign up for the full course.


"Wow, another human woman! But with black hair this time. How exciting!"

"Hi, my name is Kim."

"Hi, my name is Amigo!"

"I know. I came up with your name. Diego wouldn’t have thought that up."

"Let's get back to the lesson. I'll use simple words to explain the material to you."

"OK."

"I'd like to add a few words to what the Professor and Rishi said."

"In Java, you can write commands, but you can also add comments to those commands right in the code. The compiler completely ignores the comments. When the program is run, all the comments are omitted."

"Give me an example, please."

"Oh, sure:"

public class Home
{
    public static void main(String[] args)
    {
        /*
        Now we'll display the phrase 'Amigo Is The Best' on the screen
        */
        System.out.print("Amigo ");
        System.out.print("Is ");
        System.out.print("The ");
        System.out.print("Best");
    }
}    

"We added the comment 'Now we'll display the phrase…' The beginning of the comment is indicated by a pair of symbols (/*), and the end – by (*/). When the program is compiled, the compiler omits everything between the symbols /* and */."

"Does that mean that I can write anything I want?"

"Yes. Usually, comments in code are about parts of the code that are difficult to understand. Some comments consist of dozens of strings, often written before methods to describe nuances in how those methods work."

"There is one more way to add a comment to code. You can use two forward slashes (//)."

public class Home
{
    public static void main(String[] args)
    {
        System.out.print("Amigo ");
        System.out.print("Is The "); // This is also a comment
        System.out.print("Best");
    }
}

"Here, the code starting with the // and up to the end of the line with the // is considered to be a comment. In other words, there is no second pair of symbols used to 'complete the comment'."

"By the way, some comments are really interesting."

// I'm not responsible of this code. They made me write it, against my will.
// Dear future me. Please forgive me.
// I can't even begin to express how sorry I am.
// If I see something like this once more, I'll have a complete mental breakdown at work.
// If this condition is ever satisfied,
// please inform me for a reward. Phone: xxx-xxx-xxx.
// Dear maintainer:
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// total_hours_wasted_here = 42
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
// Sometimes I believe compiler ignores all my comments.
// I dedicate all this code, all my work, to my wife, Darlene, who will 
// have to support me and our three children and the dog once it gets 
// released into the public.
// Drunk, fix later
// Magic. Do not touch

"Yes, some comments are very funny."

"That's all for today."

"That was a short but interesting lesson. Thanks, Kim."

1
Task
New Java Syntax, level 1, lesson 6
Locked
No comments needed
Uncomment one line so that the program displays the numbers 12 and 2 (first 12, and then 2).
1
Task
New Java Syntax, level 1, lesson 6
Locked
2 + 3 = 5
Comment out a few lines to display "2 plus 3 is equal to 5" on the screen. Note: Don't comment out the lines with variable declarations.
1
Task
New Java Syntax, level 1, lesson 6
Locked
Uh... Happy New Year!
Remove comments from part of the code so that "Happy New Year" appears on the screen.
1
Task
New Java Syntax, level 1, lesson 6
Locked
Comment out the superfluous
Comment out some code so that "sum = 12" appears on the screen.
Comments (151)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Clara Borg Level 2, Ninjago City, Ninjago
11 February 2025
//Why have we not introduced Amigo to the rubber duck concept yet?
Moshood AHMED Level 2, Nigeria
7 February 2025
//java is fun
Jan Rhian Angulo Level 3, Philippines
8 December 2024
// I will rise from ZERO to Elon Musk (HERO)
Anonymous #11599292 Level 2, Bangalore, India
1 December 2024
Good
ROHITH T Level 2, CodeGym University in India, India
29 October 2024
// bro ,the interesting comments are interersting.
Omarsarr Level 1, Banjul, Gambia
1 September 2024
I understand what a comment is and how to do it but what is "uncomment"
Anonymous #11566601 Level 2, Los Angeles, United States
1 October 2024
removing the //s
One Eyed Level 3, CodeGym University in India, India
31 August 2024
idk man, i know how to code and well i farely know intermediate level java. I am just here just playing it as a game. Its fun and and i sure am learning so i guess its still a win/
Anonymous #11536884 Level 2, Bartlesville, India
3 July 2024
//I will become a strong programmer because I already learning from scratch eventhough I just completed //a course just few days back //Advance congrats to all fellow programmers
Hanz23 Level 7, United States of America, United States
11 April 2024
HI
Anonymous #11459401 Level 2, Rensselaer, United States
28 January 2024
// When I wrote this, only God and I understood what I was doing // Now, God only knows