Click here to watch in Youtube : https://www.youtube.com/watch?v=3gXPtuXWEFM&list=UUhwKlOVR041tngjerWxVccwOuterClass.java public class OuterClass
{
private String name = "John";
public void greetInEnglish()
{
class SayHello
{
/*
* We cannot declare static variable [with out final]
* in a local class.
*
* A local class can have static members provided that they are
* constant variables[final variable]
*/
public static final String message = "Welcome";
public void greet()
{
System.out.println(message);
}
}
SayHello sayHello = new SayHello();
sayHello.greet();
}
}
LocalClassTest.java public class LocalClassTest
{
public static void main(String args[])
{
OuterClass outerClass = new OuterClass();
outerClass.greetInEnglish();
}
}