public class Demo { private String[] userNames; public Demo() { userNames = new String[10]; } public void setName(String s, int n) { userNames[n] = s; } public void showName(int n) { System.out.println("Name is " + userNames[n]); } public String getName(int n) { return userNames[n]; } public static void main(String[] s) { Demo demo = new Demo(); demo.showName(2); } }