{"id":1476,"date":"2022-08-01T20:17:03","date_gmt":"2022-08-01T20:17:03","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=1476"},"modified":"2022-08-18T11:53:32","modified_gmt":"2022-08-18T11:53:32","slug":"java-scanner-nextbyte-method","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/java-scanner-nextbyte-method\/","title":{"rendered":"Java Scanner nextByte() Method"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><strong>The next byte method <\/strong><\/p>\n\n\n\n<p>If we are required to get the user input in form of a byte, we can make use of the next byte method here. So, below is the implementation of the next byte method, where we are trying to get a byte as input from the user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Scanner nextByte() method example<\/h2>\n\n\n\n<p>Here is the implementation \u2192<\/p>\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>byte storesbyte = scanner.nextByte();<br>System.out.println(storesbyte);<br>}<br>}<\/p>\n\n\n\n<p>In the above method, the user can enter a byte type data, which lies in the range from -128 to 127. If the user input lies in this range, everything is fine. But if we move out of this range, then it throws an error as the value is out of range.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The next byte method If we are required to get the user input in form of a byte, we can make use of the next byte method here. So, below is the implementation of the next byte method, where we are trying to get a byte as input from the user. Java Scanner nextByte() method [&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-1476","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\/1476","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=1476"}],"version-history":[{"count":3,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1476\/revisions"}],"predecessor-version":[{"id":2670,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1476\/revisions\/2670"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=1476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=1476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=1476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}