public class Tokenizer{
public static void main(String args[]){
String Arr[] = new String[20];
Scanner scan = new Scanner(System.in);
System.out.println("Enter a String: ");
String st = scan.nextLine();
Tokenizer tk = new Tokenizer();
tk.makeToken(st, Arr);
}
public void makeToken(String st, String Arr[]){
int i=0;
StringTokenizer Tokens = new StringTokenizer(st);
while(Tokens.hasMoreTokens()){
Arr[i]=Tokens.nextToken();
i++;
}
printToken(Arr, i);
}
public void printToken(String Arr[],int i){
for(int j=0;j<i;j++){
for(int q=1;q<=i;q++){
System.out.println(q+": "+Arr[j]);
}
}
}
}
Im trying to add numbers to this list, it needs to look like this:
1: word
2: word
3: word
and so on...basically every word that is put in needs a number by it