for example i have following code
String[] subject = new String[6];
subject[1] = JOptionPane.showInputDialog(null, "Enter subject");
String[] subject[1]=new String[6];
it will not work.There is any other way to do this?
You cant do that, unless you declare the first array as 2 dimensional
String[][] subject = new String[6][];
subject[1] = new String[6];
This code also works,
String[][] subject = new String[6][];
subject[1] = JOptionPane.showInputDialog(null, "Enter subject");
subject[1]=new String[6];
altenatively, you can use the concatination operator for adding multiple strings to the value of sub array of type String,
subject[1]=subject[1]+"first"+"second"+"third";