scanner to read string or int
hello all,
just getting into java and have a question i am sure has been asked many times. i could not find anything through the search so here is my question.
i am asking the user for some input which may be some text or an integer. how can i analyse both the string and int without knowing which will be entered?
if the user enters 1 - 9 > some action will occur, else if user enters "off" > some other action will occur.
if i add lines for ### = sc.nextInt() and ### = sc.next() after my S.O.P will that be enough? Thanks in advance.
joe