Why does Java allow method void with class name and type
                                        
                    •
                    Java                                    
                There is already an answer to this question: > methods with same name as constructor – why? 7
Example code:
//my class
class MyClass{
    //constructor
    public MyClass(.....){
    }
    //What is the use of the below method
    public void MyClass(....){
    }
}
Solution
Answer your question: No, it's of no particular use In fact, this is counterintuitive and confusing Some compilers even generate a warning that this method has a constructor name
However, since technically this may not be a compilation error, I recommend not doing so There are several different method names that can be more descriptive and have the same purpose
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        