“在 Java 语言中,你可以编写命令,但也可以在代码中为这些命令添加注释。编译器会完全忽略这些注释。当程序运行时,所有的注释都被忽略。



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 ");





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

“在这里,// 符号开头和以 // 符号结尾的代码也被认为是注释。换句话说,没有使用第二对符号来‘完成注释’。”


// 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