Yes, you can write a method in Java with method name same as class name. But it is not suggestable because of the following reasons −
public class Sample { public void Sample(){ System.out.println("This is a sample method"); } public static void main(String args[]){ Sample obj = new Sample(); obj.Sample(); } }
This is a sample method