简体   繁体   English

java 使用方法错误:他们说“无法解析符号 x”

[英]java using method error : they said "can not resolve symbol x"

在此处输入图像描述

public class MethodExemple {


    public static void main(String[] args) {



        MethodExemple methodExemple = new MethodExemple();
        methodExemple.StrCombine( x: "hello", y:"hongdroid");

        System.out.println(methodExemple.StrHongdroid( hong:"hollo"));

    }


    public void StrCombine (String x, String y) {
        String result = x + y;
        System.out.println(result);
    }

    public String StrHongdroid (String hong, String droid){ 
        String result = hong +droid;
        return result;

    }
}

I coded as I learned in class.我按照在 class 中学到的知识进行编码。 However, an error occurred only in my code.但是,仅在我的代码中发生了错误。 The contents of the error are as follows.错误内容如下。

cannot resolve symbol 'x' and 'y'无法解析符号“x”和“y”

When calling a method in Java, you shouldn't specify the argument names, just provide them in order:调用 Java 中的方法时,不应指定参数名称,只需按顺序提供即可:

methodExemple.StrCombine("hello", "hongdroid");

You don't need to include x and y when calling the method StrCombine().调用方法 StrCombine() 时不需要包含 x 和 y。 Here is the correct way methodExemple.StrCombine( "hello", "hongdroid");这是正确的方法 methodExemple.StrCombine("hello", "hongdroid"); either passing string literals like this or string variables传递这样的字符串文字或字符串变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM