如何将字符串集成到我的代码中

huangapple go评论68阅读模式
英文:

How to solve string integration to my code

问题

我目前正在跟随一个Java编程课程,导师正在将一个字符串添加到一个变量中,但在我的情况下没有显示出来。

这是我的代码:

package com.company;

public class Main {

    public static void main(String[] args) {
        // write your code here
        myName("");            // -------->> 问题在这一行,添加字符串的部分
        anotherMethod();
    }

    //方法
    public static void myName(String myName) {
        System.out.println(myName);
    }

    public static void anotherMethod() {
        System.out.println("another method");
    }
}

应该是这个样子的:

如何将字符串集成到我的代码中

怎么办?

解决方案

链接到完整代码

英文:

I'm currently following a coding course for JAVA and the tutor is adding a string to a variable but it doesn't populate for me.

Here is my code :

package com.company;

public class Main {

    public static void main(String[] args) {
        // write your code here
        myName("");            -------->>     THE PROPLEM IS IN THIS LINE TO ADD THE STRING
        anotherMethod();
    }

    //Method
    public static void  myName(String myName) {

        System.out.println(myName);

    }

    public static void anotherMethod() {

        System.out.println("another method");
    }
}

HERE IS WHAT IT SHOULD LOOK LIKE

如何将字符串集成到我的代码中

What to do?

Solution

Link the full code

答案1

得分: 2

这不是真正的源代码文本。它只是编辑器叠加的注释。当我开始使用Android Studio时,我也觉得这很奇怪和令人困惑。字体与实际文本字体非常接近,以至于它看起来像是集成到您的代码中并移动了您的文本,但它实际上不是您键入的文件中的实际文本。它有点像编辑器放置的工具提示,告诉您参数的名称。

它们被称为内联提示或具体来说是内联参数提示。它们看起来像这样:

如何将字符串集成到我的代码中

在上面的示例中,您只需键入AddCheckbox(true, true, "AutoFill", null),编辑器将会插入提示文本。

如果您不喜欢它们,可以右键单击它们,然后选择禁用提示

另请参阅:这个相关的Stack Overflow问题

英文:

So that isn't real source code text. It's just an annotation overlaid by the editor. I also found it to be weird and confusing when I started using Android Studio. The font is so close to the actual text font that it actually looks integrated into your code and moves your text over and everything, but it isn't actual text in the file that you typed. It's just kind of like a tooltip put there by the editor telling you what the name of the parameter is.

They're called inlay hints or specifically, inline parameter hints. And they look like this:

如何将字符串集成到我的代码中

In the above example, you just type AddCheckbox(true, true, "AutoFill", null) and the editor will inlay the hint text.

If you don't like them, you can disable them by right clicking on them and choosing Disable Hints.

See also: this related Stack Overflow question.

huangapple
  • 本文由 发表于 2020年10月18日 10:33:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/64409169.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定