CodeGym/课程/Java 语法/介绍一下金 (Kim)

介绍一下金 (Kim)

可用
image-zho-CN-00-21

“哇,另一个人类女人!但这个人是黑头发。太令人兴奋了!”

“嗨,我叫金。”

“嗨,我叫阿米戈!”

“我知道。我为你取的名字。迭戈是不会想出这个名字的。”

阿米戈的思想以电子的速度飞奔起来。“嗯......她太好了......我不知道她是否喜欢机器人。”

“让我们回到课程上来。我将用简单的语言向你解释这些内容。”

“好的。”

“我想对教授和里希所说的话补充几句。”

“在 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 ");
        System.out.print("Best");
    }
}

“我们添加了‘现在我们将在屏幕上显示......’这一注释。该注释的开头应以一对(/*)符号来标记,而结尾用一对(*/)符号来标记。当编译程序时,编译器会忽略/*符号和*/符号之间的所有内容。

“这是否意味着我可以写任何我想写的东西?”

“是的。通常,代码中的注释内容是说明关于代码中难以理解的部分。有些注释由几十个字符串组成,通常写在一些方法的前面,以描述这些方法如何工作的细微差别。”

“还有一种方法可以为代码添加注释。你可以使用两个斜杠(//)。”

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

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

“顺便说一句,有些注释真的很有趣。”

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

“是的,有些注释非常好笑。”

“今天就讲到这里。”

“这堂课很短,但很有趣。谢谢,金。”

评论 (129)
  • 受欢迎
你必须先登录才能发表评论
Anonymous #11598970
级别 1 ,Shenzhen,China
29 十一月 2024, 09:16
这里的描述是不能这么介绍知识点把, 这里就是注释的说明,用法,有哪几种注释方式的; // 行注释 /* * 多行注释 */ /** * 文档注释 */
Anonymous #11576220
级别 1 ,Zhengzhou,China
9 十月 2024, 09:21
注释……………………
小爱神.
级别 1 ,Yueyang,China
1 九月 2024, 02:21
这不是短,而是嫖我们的暗物质
Anonymous #11556212
级别 2 ,Beijing,中国
28 八月 2024, 08:27
System.out.println("太水了!");
Anonymous #11556936
级别 1 ,Suzhou,China
24 八月 2024, 05:36
我需要新的暗物质
yufei du
级别 1 ,United States of America,United States
18 八月 2024, 12:53
System.out.println("很水");
葛天昱
级别 1 ,China,China
17 八月 2024, 06:59
System.out.println("很水");
Anonymous #11520764
级别 1 ,Guilin,China
26 五月 2024, 02:15
// SHIT
一点半
级别 2 ,Beijing,China
22 四月 2024, 05:49
/* */ //??
萧萧🥬🥒
级别 7 ,China,China
2 四月 2024, 10:20
//已阅读 /* 我爱你 */