class Separate {//begin class public static void main(String args[]) {//begin main /**This program separates a String fed into it as //command line parameters and then separates the //different words by a second command line //parameter, meaning you type //"java Separate first,second,third,fourth,fifth ," //and it separates the words by the comma which //is the second command line parameter entered, //right now it's set up to output how many different //sections there are, and then putting them //each out as a separate line */ String temp1 = args[0]; String charSeparator = args[1]; String tempArray1[] = new String[temp1.length()+1]; int temp1Length = temp1.length(); int tempArray1Length = 0; int tempArray2Length = 0; int location1 = 0; String arrayValueTransfer; for (int i = 0; i <= temp1Length; i++) {//loop start; for finding the number of fields and separating them location1 = temp1.indexOf(charSeparator); if (location1 >= 0) {//if true, start; more fields still exist tempArray1[i] = temp1.substring(0, location1); temp1 = temp1.substring(location1 + 1); }//if true, end; else {//if false, start; one last field tempArray1[i] = temp1; tempArray2Length = i; i = temp1Length; }//if false, end; }//loop end; String tempArray2[] = new String[tempArray2Length+1]; tempArray1Length = tempArray1.length; System.out.println(tempArray2Length+1); for (int i = 0; i <= tempArray2Length; i++) {//loop start; loop for transfering values into second array and printing them arrayValueTransfer = tempArray1[i]; tempArray2[i] = arrayValueTransfer; System.out.println(tempArray2[i]); }//loop end; }//end main }//end class