String namesStr;
int position = 0;
namesStr = JOptionPane.showInputDialog("Enter names separated by commas");
position = namesStr.indexOf(",");
firstStr = namesStr.subString(0, position);
-------------------
The problem in my code is in the line:
firstStr = namesStr.subString(0, position);
What is wrong with the code? is it not assigning the string between position 0 and the position of the first comma to the variable firstStr?
int position = 0;
namesStr = JOptionPane.showInputDialog("Enter names separated by commas");
position = namesStr.indexOf(",");
firstStr = namesStr.subString(0, position);
-------------------
The problem in my code is in the line:
firstStr = namesStr.subString(0, position);
What is wrong with the code? is it not assigning the string between position 0 and the position of the first comma to the variable firstStr?