{"id":1498,"date":"2022-08-01T21:02:37","date_gmt":"2022-08-01T21:02:37","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=1498"},"modified":"2022-08-18T13:31:14","modified_gmt":"2022-08-18T13:31:14","slug":"scanner-hasnextfloat-method-java","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/scanner-hasnextfloat-method-java\/","title":{"rendered":"Scanner hasNextFloat() Method in Java"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><strong>hasNextFloat method in java<\/strong><\/p>\n\n\n\n<p>If we are required to check whether or not, the input by the user is of float type, then we can use this method, hasNextFloat. Well, this method returns true, if the given user input can be interpreted as float-type data. Otherwise, the method returns false.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checking if the user input is float type(hasNextFloat method)<\/h2>\n\n\n\n<p>Let&#8217;s have a look at an example, where we try demonstrating the hasNextFloat method. <\/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>boolean storesfloat = scanner.hasNextFloat();<br>System.out.println(storesfloat);<br>}<br>}<\/p>\n\n\n\n<p>If you try to implement the above program and give some floating type input, the method is going to return true, else it is going to return false for any other input. <\/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>boolean storesfloat = scanner.hasNextFloat();<br>System.out.println(storesfloat);<br>}<br>}<\/p>\n\n\n\n<p>So, if you try implementing the above program and give some floating type input, the method is going to return true, else it is going to return false.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>hasNextFloat method in java If we are required to check whether or not, the input by the user is of float type, then we can use this method, hasNextFloat. Well, this method returns true, if the given user input can be interpreted as float-type data. Otherwise, the method returns false. Checking if the user input [&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-1498","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\/1498","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=1498"}],"version-history":[{"count":3,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1498\/revisions"}],"predecessor-version":[{"id":2680,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1498\/revisions\/2680"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=1498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=1498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=1498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}