Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringTokenizer类😊 #8

Open
Panda-Z-Coding opened this issue Jun 24, 2024 · 0 comments
Open

StringTokenizer类😊 #8

Panda-Z-Coding opened this issue Jun 24, 2024 · 0 comments

Comments

@Panda-Z-Coding
Copy link
Owner

StringTokenizer类

前言:StringTokenizer类split() 不同之处在于前者不使用正则表达式做分隔标记

  • 两种构造方法

StringTokenizer(String s)               //为s构造一个分析器,使用默认分隔符 
StringTokenizer(String s,String delim)  //为s构造一个分析器,参数delim的字符的 任意排列 作为分隔标记
  • StringTokenizer的操作方法

我们称StringTokenizer对象是一个字符序列分析器,它封装的数据是若干个单词。
所以我们就有两种常见的方法来操作里面的单词

  .nextToken();       //返回一个单词,并从分析器里删除它
  .hasMoreTokens();   //判断还有没有单词
  .countTokens();     //返回当前的单词数
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant