In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "the introduction of java Scanner class and the process parsing of inputting numbers and strings". In daily operation, I believe many people have doubts about the introduction of java Scanner class and the process parsing of inputting numbers and strings. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful for you to answer the doubts of "the introduction of java Scanner class and the process of parsing input numbers and strings". Next, please follow the editor to study!
Introduction to Scanner Class
Java 5 adds the java.util.Scanner class, a new utility for scanning input text. It is some kind of combination between the previous StringTokenizer and Matcher classes. Because any data must be retrieved through a capture group of the same pattern or by using an index to retrieve parts of the text. You can then combine regular expressions with methods to retrieve specific types of data items from the input stream. In this way, in addition to using regular expressions, the Scanner class can analyze data of string and basic types such as int and double at will. With Scanner, you can write a custom parser for any text content you want to work with.
Scanner input numbers, strings
Package java05;import java.util.Scanner / / 1. The function of the guide package / * Scanner class, which can be used to input data from the keyboard to the first class of reference types in the program: 1. Guide package 2, create 3, use to get an int number entered by the keyboard, and int num = sc.nextInt () to get a str string entered by the keyboard String str = sc.next () * * / public class DemoScanner {public static void main (String [] args) {/ / create / / Note: System.in stands for typing from the keyboard Scanner sc = new Scanner (System.in) / / 3. Get the keyboard input int number int num = sc.nextInt (); System.out.println ("the input number is:" + num); / / get the keyboard input string String str = sc.next (); System.out.println ("the input string is:" + str) }} at this point, the study on "the introduction of the java Scanner class and the process of parsing input numbers and strings" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.