Java Constructor Overloading

前端 未结 5 508
慢半拍i
慢半拍i 2021-01-29 16:13

I\'m new with Java and I\'m having trouble understanding the constructor issue, I have looked at many tutorials and still I\'m having difficult to understand why we use construc

5条回答
  •  感情败类
    2021-01-29 16:54

    Adding to the @brso05 answer,

    This is also one of the ways:

    public MyClass( int a)
    {
    }
    
    public MyClass( int a, int b)
    {
    }
    
    public MyClass( int a, String b)
    {
    }
    

    And So on..It is the arguments which make difference, rest remains the same!

提交回复
热议问题