how do i get the inputed strings to print out after i turn them into tokens ? I need it to ask for a number and then multiple lines of strings, turn them into tokens, then print them out.
import java.util.*; public class TokenDriver{ public static void main(String [] args){ // TokenStore words = new TokenStore(); String[] tokens = new String[300]; Scanner scan = new Scanner(System.in); Scanner scan2 = new Scanner(System.in); System.out.println("enter number of words to display per line"); int num = scan.nextInt(); System.out.println(num); //scan.nextLine(); System.out.println("Enter lines of text, type two returns in a row to end"); String t = " "; int pos = 0; String[] store = new String[300]; while(t.length() > 0) { t = scan2.nextLine(); store[pos] = t; pos++; } StringTokenizer str = new StringTokenizer(t); while(str.hasMoreTokens()) { String token = str.nextToken(); System.out.println(token); }
--- Update ---
also as a follow up how would use an array in an other class (TokenStore) to save the typed line information