+ 1

How to access name and age in main method...??

import java.util.*; public class Main { } class Person{ class Student{ String name; int age; } }

9th Oct 2018, 8:17 AM
Nishant Shekhar Soni
Nishant Shekhar Soni - avatar
1 Answer
+ 5
Best way is to make getters and setters. That are methods which can set the value of a variable of the class. and the getters return the value of the variable of the class.
9th Oct 2018, 8:32 AM
Willem Roos