Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common methods of StringTokenizer class in Java

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you what are the common methods of the StringTokenizer class in Java, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

JavaStringTokenizer belongs to the java.util package and is used to separate strings.

StringTokenizer construction method:

1.StringTokenizer (Stringstr): construct a StringTokenizer object to parse str. The default delimiters for java are spaces (""), tabs (\ t), line feeds (\ n), and carriage returns (\ r).

2.StringTokenizer (Stringstr,Stringdelim): constructs a StringTokenizer object to parse str and provides a specified delimiter.

3.StringTokenizer (Stringstr,Stringdelim,booleanreturnDelims): constructs a StringTokenizer object to parse the str, provides a specified delimiter, and specifies whether the delimiter is returned.

Common methods of StringTokenizer:

1.intcountTokens (): returns the number of times the nextToken method was called.

2.booleanhasMoreTokens (): returns whether there is a delimiter.

3.booleanhasMoreElements (): returns whether there is a delimiter.

4.StringnextToken (): returns a string from the current position to the next delimiter.

5.ObjectnextElement (): returns a string from the current position to the next delimiter.

6.StringnextToken (Stringdelim): similar to 4, the result is returned with the specified delimiter.

These are all the contents of this article entitled "what are the common methods of StringTokenizer classes in Java?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report