I normally could do this, it's very simple code, but I'm having one hell of a brain-fart and I'm eager to figure out my stupidity. I wrote this real quick to try out a new IDE I heard about, and it's supposed to take an inputted string and return it with the words in reverse order, but it keeps on telling me that at some point one of the indices of the String[] have no value.
import java.util.StringTokenizer;
import java.util.Scanner;
public class Example {
/**
* @param args
*/
public static void main(String[] args) {
//set up input
Scanner input=new Scanner(System.in);
System.out.println("type something here");
String sentence=input.nextLine();
//set up StringTokenizer
StringTokenizer tokens=new StringTokenizer(sentence);
//setup for loop
for(int y=tokens.countTokens()-1; y>=0; y--){
String[] word={tokens.nextToken()};
System.out.print(word[y]+" ");
}
}
}