I do not want my class inherited by other class then What should I do

I do not want my class inherited by other class then What should I do ?

Answer : Define class with final keyword. Please see below:

final class Test {
	static void testMethod() {
		System.out.println("Multiple class test");
	}
}

 

Leave a Reply

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