Hello
i want to add some variables to an array and i want to use for loop beacuase I have 500 varibles and i cant do this
names[350] = var; names[351] = var; names[352] = var; names[353] = var;
this will take 500 lines so i want to use a for loop but i don't know how to add each variable to an element of the array.
private void List() { String one = "Hello", two = "How", three = "Are", four = "You"; String[] names = new String[4]; names[0] = one; names[1] = two; names[2] = three; names[3] = four; /* for(int i=0; i<names.length; i++) { names[i] += one; names[i] += two; names[i] += three; names[i] += four; }*/ JList list = new JList(names); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSize(100, 100); list.setLocation(100, 100); ContentPane.add(list); }