Multiline String input using Java

preview_player
Показать описание
How to collect multiple line string input and display as output
Рекомендации по теме
Комментарии
Автор

Nice vid. One tip for everyone, after the while loop, write "scan.nextLine();" to consume the newline character. Otherwise any future input may take it in instead and behave weirdly

Nomnomnom
Автор

That works even of you don't use the While Loop.

joelnadar
Автор

it is not working, it is not closing the scanner

helloworld
Автор

I am trying to read multiple likes but this is not working. could you please help me with this
package learn.basic;

import java.util.Scanner;

public class ReadMultipleLines {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

String str;
s.useDelimiter("//t");
while(true) {
str = s.nextLine();

break;
}
System.out.println(str);
s.close();

}

}

nethravathim
Автор

package learn.basic;

import java.util.Scanner;

public class ReadMultipleLines {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

String str;
s.useDelimiter("//t");
while(true) {
str = s.next();
break;
}
System.out.println(str);
s.close();

}

}
this is also entering infinite loop

nethravathim