📜  Java.util.StringTokenizer类

📅  最后修改于: 2020-11-14 06:25:01             🧑  作者: Mango


介绍

java.util.StringTokenizer类允许应用程序将字符串分成令牌。

  • 此类是一个遗留类,出于兼容性原因而保留,尽管在新代码中不建议使用。

  • 它的方法不区分标识符,数字和带引号的字符串。

  • 此类方法甚至无法识别和跳过注释。

类声明

以下是java.util.StringTokenizer类的声明-

public class StringTokenizer
   extends Object
   implements Enumeration

类的构造函数

Sr.No. Constructor & Description
1

StringTokenizer(String str)

This constructor a string tokenizer for the specified string.

2

StringTokenizer(String str, String delim)

This constructor constructs string tokenizer for the specified string.

3

StringTokenizer(String str, String delim, boolean returnDelims)

This constructor constructs a string tokenizer for the specified string.

类方法

Sr.No. Method & Description
1 int countTokens()

This method calculates the number of times that this tokenizer’s nextToken method can be called before it generates an exception.

2 boolean hasMoreElements()

This method returns the same value as the hasMoreTokens method.

3 boolean hasMoreTokens()

This method tests if there are more tokens available from this tokenizer’s string.

4 Object nextElement()

This method returns the same value as the nextToken method, except that its declared return value is Object rather than String.

5 String nextToken()

This method returns the next token from this string tokenizer.

6 String nextToken(String delim)

This method returns the next token in this string tokenizer’s string.

方法继承

此类从以下类继承方法-

  • java.util.Object