简体   繁体   English

在我的方法实例中找不到符号?

[英]Can't Find Symbol in my method instance?

This a very quick and i feel obvious mistake but i keep getting the CANNOT FIND SYMBOL 这非常快,我感觉到明显的错误,但是我不断收到无法找到的符号

symbol : method print(int,int)

this would lead me to believe that i'm not giving the method the right data type parameters, however.. 但是,这会让我相信我没有为该方法提供正确的数据类型参数。

public class Test
{
    public static void main(String[] args)
    {
        TestSrv srvObj = new TestSrv();

        srvObj.print(0, 0);
        srvObj.print(1, 1);
        srvObj.print(2, 10);
    }
}

and this method, what it's meant to do aside, i keep getting errors from the above code for all 3 calls to the print method? 和这个方法,除了我要做什么以外,对于上述对print方法的所有3次调用,我仍然从上面的代码中得到错误消息吗? I am passing it integers on all 3 occasions? 我在所有3次场合都传递整数吗?

 public class TestSrv
    {
        public void print(int num, int count)
            {
                for (int i = 0; i <= count; ++i)
                {
                    System.out.print(num + ". " + "*");
                }
            }       
    }

Your code should compile. 您的代码应编译。 Make sure that you declare both classes in the same package or that you import TestSrv in Test.java. 确保在同一个程序包中声明两个类,或者在Test.java中导入TestSrv。

You almost certainly didn't compile TestSrv after making changes. 几乎可以肯定的是,进行更改后没有编译TestSrv Using an IDE such as Eclipse or IDEA will take care of much of that detail for you. 使用Eclipse或IDEA之类的IDE将为您处理很多细节。

while renaming my method and class and such so that it wasn't what i originally named it(as to not confuse anyone) i actually fixed the problem that i had.. that is why this compiled for everyone xD i feel stupid! 在重命名我的方法和类时,这样就不是我最初命名的名称了(为了不混淆任何人),我实际上解决了我遇到的问题。这就是为什么为每个xD编译的代码我都觉得很愚蠢! thanks again 再次感谢

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

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