Java Comments
You want a note in the file for yourself, and you want the screen to stay the same. The screen is still mint. The note is for a person reading Mint.java. It is not a word for the screen. This page adds that note in two shapes, shows that mint is still the only line, and then shows the one placement that removes mint. You are not installing Java again. You are not looking for which line writes the screen. You already know that line is System.out.println("mint"). The new work is the note beside it.
A note is not a command
A command is a line Java carries out. System.out.println("mint") is a command. It writes mint and ends the line. A note is text you leave in the file so that you, or the next reader, remember something. Java skips a note. Skipping means the note is not carried out, and it is not written on the screen. The letters of the note stay in the file after the run. You can open Mint.java and read them. You cannot find them on the screen. The screen still has one line, and that line is mint, as long as the writing command itself is not the note.
There are two shapes. A line note starts with two slashes, //. Java skips from those two slashes through the end of that same line. The next line is a normal line again. A block note starts with / and ends at the first /. Java skips everything between those two marks, including the line breaks. A block note can sit on one line or across several. Both shapes are notes. Neither shape writes the screen. The slashes are not printed. The stars are not printed. The words you put between them are not printed.
The file you keep
Save this as Mint.java. It is the file this page keeps. It has a line note above the writing command, another line note on the writing command's own line, and a line note above main. The writing command is still there, and it is not behind a slash.
public class Mint {
// the file is named Mint.java
public static void main(String[] args) {
// a note for the reader
System.out.println("mint"); // the screen is this word
}
}
Read it from the top, and decide for each line whether the screen receives it. The first line is still public class Mint. You already know that line names the file and does not write the screen. The next line is // the file is named Mint.java. The two slashes start a note, so the words the file is named Mint.java are for you. The screen does not show them. It also does not show the slashes. The line public static void main(String[] args) is where Java starts, and none of those words are on the screen. That has not changed.
Inside main, the line // a note for the reader is only a note. Java reaches it, skips it, and goes to the next line. The next line is the one that matters: System.out.println("mint"); // the screen is this word. Read that line as two parts split by the slashes. Before the slashes, the command is System.out.println("mint");. That command writes mint and ends the line. After the slashes, the words the screen is this word are a note. They sit on the same line as the command, and they are still skipped. A note does not have to occupy a line by itself. If // appears after a finished command, the command runs and the rest of the line does not. The semicolon is what finishes the command. The slashes after the semicolon start the note. Leave that semicolon where it is. The screen shows mint. It does not show the screen is this word. It does not show a second line.
Run it the same way as before. In the folder that contains this Mint.java, type javac Mint.java. When the file is fine, that command writes no line. The notes do not make javac write a line, and they do not make it fail. Then type java Mint. Do not type .java after java. The screen shows mint. One line. No quotes. No slashes. No second line. The word mint is still the word between the quotes. It is not a word you typed in the command, and it is not a word you typed in a note.
A block note
A block note is the other shape. You use it when the note is longer than one line, or when you want the end of the note to be a mark you choose, not the end of the line. The opening mark is /. The closing mark is /. Java skips from the opening through the closing, and the first / is the end. A later / is not part of this note, because the note already ended. This page uses one block note, so you will see one opening and one closing.
Replace the line notes inside main with one block note, and leave the writing command in place. The screen does not change. This is the second file. You are looking at what the note looks like. The file you were keeping used line notes. This one uses a block note. Both write mint.
public class Mint {
public static void main(String[] args) {
/* a note
across two lines */
System.out.println("mint");
}
}
The block note begins on the line that starts with /. The words a note are inside it. The next line, across two lines, is inside it too, because the closing / has not appeared yet. The / at the end of that second line ends the note. Java then runs System.out.println("mint"); because that command is outside the note, below the closing mark. The screen shows mint. The words a note and across two lines are not on the screen. The stars and the slashes are not on the screen. If you move the / up so that it sits on the first line, right after a note, then the second line is no longer inside the note. That second line would have to be a real Java line, and across two lines is not a command. javac would write an error instead of staying quiet. On this page the */ stays at the end of the second line, so the whole note is skipped and javac stays quiet.
Do not try to put one block note inside another. The first / ends the note, even if you meant that / to end an inner note. After that first closing mark, Java is reading commands again. This page does not nest notes. One opening, one closing, then the writing command.
The mistake that removes mint
The note and the writing command are different lines, or different parts of one line, in the files above. The mistake is to put the two slashes in front of the writing command, so that the command becomes the note. Save this third file only long enough to see the empty screen, then put the writing command back. This is not the file you keep.
public class Mint {
public static void main(String[] args) {
// System.out.println("mint");
}
}
javac Mint.java still writes no line, because a file that only skips a note is still a valid file. Java starts at main, skips the only line inside it, and finishes. java Mint then writes nothing. There is no mint. There is no empty quoted word. There is no second line. The screen is blank because the command that used to write mint is behind //. The letters System.out.println("mint") are still in the file, and you can read them, but they are a note now. The quotes do not save them. Quotes mark a word inside a command. They do not turn a note back into a command. The two slashes in front decide, and they decide that the rest of the line is for the reader.
Put the file back to the one you keep. The writing line must be System.out.println("mint"); with the note, if you want one, after the semicolon. Then java Mint writes mint again. If the screen is blank, look for // before System.out. That is the whole check. You do not reinstall Java for a blank screen caused by a note.
A note can contain any words, including Mint, main, and mint. Those words are still not on the screen. The screen uses the word between the quotes of a command that actually runs. In the file you keep, that word is mint, with a small m. A note that says Mint, with a capital M, does not make the screen show Mint. A note that repeats mint does not write a second line. The run does not delete the note from the file. Open the file after java Mint and the note is still there.
You can now put a note in Mint.java without changing the screen. A line note starts with //. A block note starts with / and ends at the first /. The screen of the file you keep is mint, written by System.out.println("mint"). If // stands in front of that command, the screen has no line. The next page changes the word between the quotes, so the screen shows a different word. The notes on this page stay notes.
The screen is still mint
The file you keep writes mint. Notes that start with // are not on the screen. A note between / and / is not on the screen. The first */ ends that note. The screen has one line. There is no second line.
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top