June 14, 2024

Anonymous inner class can have multiple methods ?

Yes. Its possible. You can have multiple methods in anonymous inner class. Check the below example.

interface myInterface {
    void welcome(String string);
    void test();

public class innerClassTest {

	public static void main(String[] args) {

		myInterface obj = new myInterface() {
        	public void welcome(String string) {
        		System.out.println("welcome method");
        	public void test() {
        		System.out.println("test method");


One thought on “Anonymous inner class can have multiple methods ?

Leave a Reply

Your email address will not be published. Required fields are marked *