how to use inner class and where please give an example | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

how to use inner class and where please give an example

12th Mar 2017, 7:50 AM
Roshan Kumar
Roshan Kumar - avatar
1 Answer
+ 1
public class SuperC{ int x; int y; protected class InnerClass{ public void increment(int num) { return ++num; } } here you have an inner class encapsulated inside a class, only this class and his inheritances can access this inner class. that can help you if you want "hide" methods from another classes
12th Mar 2017, 6:21 PM
Oriel
Oriel - avatar