The Scanner class method used to accept words with space:
nextLine()
Reason — nextLine() reads the input till the end of line so it can read a full sentence including spaces.