A good reference for starting is:
The Really Big Index
I am with you, I am learning this too. The method I am using is:
First import:
import java.util.Scanner;
Then in the main part of the program:
Scanner keyboard = new Scanner(System.in);
String input = "g";
// Get questions one by one, provide answer as each new question is started.
while(randNumberList.size() != 0 && !input.equals("q")){
System.out.print("Count: " + randNumberList.size() + " --------------------------------------------------------------------");
qna = qaArrayList.get(randNumberList.get(0));
System.out.print("\nQuestion number " + qna.getQEntriesArray(0) + ":\n" + qna.getQuestion());
if(randNumberList.size() > 0)
randNumberList.remove(0);
input = keyboard.nextLine();
System.out.print(qna.getAnswer() + "\n");
}
keyboard.close();
}
Some of the code in the while loop is part of my question and answer
program that reads a question from a file and then when you hit any
key other than "q", it gives you the answer and the next question, so
it is not directly related to the function of getting input.
--- Update ---
[/COLOR]So If I hack out some of the superfluous code:
Scanner keyboard = new Scanner(System.in);
String input = "g";
while(!input.equals("q")){
System.out.print("Input what you want to . . . ");
input = keyboard.nextLine();
// Do whatever it is you want to do
// it might be a good place for a switch statement
// if you are using an up-to-date version of java:
// using switch(input)
// an older version of Java will not accept a string in the switch statement!
}
keyboard.close();
}