Log in

View Full Version : What is local class in java ?



Shivangi Panwar
06-18-2016, 08:09 AM
What is local class in java ?


itil service transition training (http://gogotraining.com/training/courses/240/itil-2011-service-transition--axelos-and-exin-accredited-training/) itil service operation training (http://gogotraining.com/training/courses/237/itil-2011-service-operation--axelos-and-exin-accredited-training/) itil service design training (http://gogotraining.com/training/courses/238/itil-2011-service-design--axelos-and-exin-accredited-training/) itil service strategy training (http://gogotraining.com/training/courses/239/itil-2011-service-strategy--axelos-and-exin-accredited-training/)

Ashly85
06-20-2016, 06:32 AM
Inner classes let you define one class within another.

They provide a type of scoping for your classes since you can make one class a member of another class.

Just as classes have member variables and methods, a class can also have member classes.

class Outer {
/class Inner { }
}// End of class

if you compile it,
%javac Outer.java


you’ll end up with two class files:
Outer.class
Outer$Inner.class

sanjalisharma89
06-22-2016, 07:45 AM
A class i.e. created inside a method is called local inner class in java.

BrilltechEngg
06-28-2016, 08:35 AM
3.11. Local Classes. A local class is declared locally within a block of Java code, rather than as a member of a class. Typically, a local class is defined within a method, but it can also be defined within a static initializer or instance initializer of a class.

chrisgeitz
06-29-2016, 04:01 AM
Local classes are nothing but the inner classes I.e. the class defined inside another class.

johnseward
06-30-2016, 02:11 AM
created inside a method is called local inner class in java. If you want to invoke the methods of local inner class, you must instantiate this class inside the method
public class localInner1{
private int data=30;//instance variable
void display(){
class Local{
void msg(){System.out.println(data);}
}
Local l=new Local();
l.msg();
}
public static void main(String args[]){
localInner1 obj=new localInner1();
obj.display();
}
}

druckexpert
08-01-2016, 10:00 AM
A local class is declared locally within a block of Java code, rather than as a member of a class.