what is final class?

A class declared as final cannot be a Base class, that means any other class cannot inherit from final class.
For example String, StringBuffer, Integer, Float, Byte and other wrapper classes(all classes listed here are in java.lang package) are final, and hence we cannot inherit from these classes.

Even, we can define final class. Below is an example, which is not compilable, due to final class

final class A1
{
public void show()
{
System.out.println(“show() in A1”);
}
}

class B1 extends A1 //if A1 is final class, error occurs
{
public void show()
{
System.out.println(“show() in B1”);
}
}

public class FinalDemo {
public static void main(String args[])
{
B1 ob = new B1();
}
}

You may also like to read:Purpose of final method