{"id":1467,"date":"2022-08-01T20:00:53","date_gmt":"2022-08-01T20:00:53","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=1467"},"modified":"2022-08-18T11:51:38","modified_gmt":"2022-08-18T11:51:38","slug":"scanner-nextline-java","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/scanner-nextline-java\/","title":{"rendered":"Scanner Nextline Java"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><strong>The nextLine method in Java<\/strong><\/p>\n\n\n\n<p>As we can get from the name, we can simply say that we are going to get the line as an input. So, whenever we are in such a situation, that we need some line from the user as input, we can make use of the nextLine method.<\/p>\n\n\n\n<p>Below is the implementation of the nextLine() method &#8211; <\/p>\n\n\n\n<h2 class=\"has-text-align-center wp-block-heading\">Read input till the end of line (nextLine method)<\/h2>\n\n\n\n<p class=\"has-white-color has-black-background-color has-text-color has-background\">package com.company;<br>import java.util.Scanner;<br>public class Main {<br>public static void main(String[] args) {<br>Scanner scanner = new Scanner(System.in);<br>String text_with_spaces = scanner.nextLine();<br>System.out.println(text_with_spaces);<br>}<br>}<\/p>\n\n\n\n<p>So, now if you try implementing this program, you can see that the spaces are also considered.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The nextLine method in Java As we can get from the name, we can simply say that we are going to get the line as an input. So, whenever we are in such a situation, that we need some line from the user as input, we can make use of the nextLine method. Below is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[12,11],"class_list":{"0":"post-1467","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-java-tutorial","7":"tag-java","8":"tag-java-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=1467"}],"version-history":[{"count":4,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1467\/revisions"}],"predecessor-version":[{"id":2668,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1467\/revisions\/2668"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=1467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=1467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=1467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}