I'm attempting to take a user inputted phrase that is greater than one line and turn it into one string. I guess I'm confused by how hasNext() works because I thought it would return as false if there was blank space. How can I fix my while loop so that it breaks once it reaches the end of the phase? Or how can I achieve this in general?
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
String text="";
String s="";
while(scan.hasNext()){
s=scan.nextLine();
text+=s;
System.out.println(text);
}