Answers for "readline in java"

1

getline in java

// Java program to illustrate the
// nextLine() method of Scanner class in Java
// without parameter

import java.util.*;

public class GFG1 {
	public static void main(String[] argv)
		throws Exception
	{

		String s = "Gfg \n Geeks \n GeeksForGeeks";

		// create a new scanner
		// with the specified String Object
		Scanner scanner = new Scanner(s);

		// print the next line
		System.out.println(scanner.nextLine());

		// print the next line again
		System.out.println(scanner.nextLine());

		// print the next line again
		System.out.println(scanner.nextLine());

		scanner.close();
	}
}
Posted by: Guest on October-10-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language