Home > Blockchain >  java using method error : they said "can not resolve symbol x"
java using method error : they said "can not resolve symbol x"

Time:12-19

enter image description here

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. However, an error occurred only in my code. The contents of the error are as follows.

cannot resolve symbol 'x' and 'y'

CodePudding user response:

When calling a method in Java, you shouldn't specify the argument names, just provide them in order:

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

CodePudding user response:

You don't need to include x and y when calling the method StrCombine(). Here is the correct way methodExemple.StrCombine( "hello", "hongdroid"); either passing string literals like this or string variables

  • Related