Which method is looked first by Compiler , Static or instance method when ClassName.method() is used?

前端 未结 4 1287
忘了有多久
忘了有多久 2021-01-16 06:44

I want to get proper understanding why below compilation error? As per my understanding If i use Test.xyz() then compiler look for only static method not for instance method

4条回答
  •  孤街浪徒
    2021-01-16 07:32

    This is how I did the static class.

    public class test {
           public static void main(String arg[]) {
            xyz(10);    
            }     
    
            public static void xyz(int i) {
            }   
        }
    

提交回复
热议问题