SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Java.util packages
String tokenizers
● The java.util.StringTokenizer class allows an
application to break a string into tokens.
● This class is a legacy class that is retained for
compatibility reasons although its use is
discouraged in new code.
● Its methods do not distinguish among identifiers,
numbers, and quoted strings.
● This class methods do not even recognize and
skip comments.
Constructors in String tokenizers
Constructors Description
StringTokenizer(String str) This constructor a string tokenzier for the
specified string
StringTokenizer(String str,String delim) This constructor constructs string
tokenizers for the specified string
StringTokenizer(String str, String delim,
boolean returnDelims)
This constructopr constructs a string
tyokenizer for the specified string.
Methods in StringTokenizer
Method Description
Int countTokens() This method calculates the number of
times that this tokenizer's nextToken
method can be called before it generates
an exception
Boolean hasMoreElements() This method returns the same value as
the hasMoreTokens method
Boolean hasMoreTokens() This method tests if there are more
tokens available from this tokenizer's
string
Object nextElement() This method returns the same value as
the nextToken method, except that its
declared return value is Object rather
than string
String nextToken() This method returns the next token from
this string tokenizer
String nextToken(String delim) This method returns the next token in this
string tokenizer's string
Sample program using
StringTokenizer
Sample output

More Related Content

PPTX
Method overloading
PPS
String and string buffer
PPTX
PPTX
Interface in java
PPT
Java interfaces
PPT
Java static keyword
PPTX
Super Keyword in Java.pptx
PPTX
Constructor in java
Method overloading
String and string buffer
Interface in java
Java interfaces
Java static keyword
Super Keyword in Java.pptx
Constructor in java

What's hot (20)

PPTX
Constructor and Types of Constructors
PPTX
Strings in Java
PPTX
Java string handling
PPTX
Java Foundations: Methods
PPTX
Chapter 05 classes and objects
PPTX
Templates in C++
PPTX
Java Method, Static Block
PPTX
INHERITANCE IN JAVA.pptx
PPTX
Classes, objects in JAVA
PPTX
Methods in java
PPTX
Constructor in java
PPTX
Inheritance in c++
PPTX
Type casting in java
PPTX
[OOP - Lec 19] Static Member Functions
PDF
Constructors and Destructors
PPTX
Arrays in Java
PPT
Method overriding
PPTX
Data types in c++
PPTX
Control statements in java
PPS
Introduction to class in java
Constructor and Types of Constructors
Strings in Java
Java string handling
Java Foundations: Methods
Chapter 05 classes and objects
Templates in C++
Java Method, Static Block
INHERITANCE IN JAVA.pptx
Classes, objects in JAVA
Methods in java
Constructor in java
Inheritance in c++
Type casting in java
[OOP - Lec 19] Static Member Functions
Constructors and Destructors
Arrays in Java
Method overriding
Data types in c++
Control statements in java
Introduction to class in java
Ad

More from Muthukumaran Subramanian (20)

PPTX
Struts introduction
PDF
Operators in java
PDF
Threads concept in java
PDF
Overriding methods
PDF
Oops (inheritance&interface)
PDF
Non access modifiers
PDF
Jdbc connectivity in java
PDF
Garbage collection in java
PDF
PDF
Exception handling
PDF
Currency class
PDF
Timer class in java
PDF
Calendar class in java
PDF
Classes and objects in java
PDF
intorduction to Arrays in java
PDF
Access modifiers in java
PDF
Abstract classes
PDF
Java introduction
PDF
Collections and generics
Struts introduction
Operators in java
Threads concept in java
Overriding methods
Oops (inheritance&interface)
Non access modifiers
Jdbc connectivity in java
Garbage collection in java
Exception handling
Currency class
Timer class in java
Calendar class in java
Classes and objects in java
intorduction to Arrays in java
Access modifiers in java
Abstract classes
Java introduction
Collections and generics
Ad

Recently uploaded (20)

PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Cell Types and Its function , kingdom of life
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Classroom Observation Tools for Teachers
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Structure & Organelles in detailed.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Pre independence Education in Inndia.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Module 4: Burden of Disease Tutorial Slides S2 2025
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Cell Types and Its function , kingdom of life
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Complications of Minimal Access Surgery at WLH
Classroom Observation Tools for Teachers
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Structure & Organelles in detailed.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pre independence Education in Inndia.pdf
Institutional Correction lecture only . . .
Abdominal Access Techniques with Prof. Dr. R K Mishra
2.FourierTransform-ShortQuestionswithAnswers.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?

StringTokenizer in java

  • 2. String tokenizers ● The java.util.StringTokenizer class allows an application to break a string into tokens. ● This class is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. ● Its methods do not distinguish among identifiers, numbers, and quoted strings. ● This class methods do not even recognize and skip comments.
  • 3. Constructors in String tokenizers Constructors Description StringTokenizer(String str) This constructor a string tokenzier for the specified string StringTokenizer(String str,String delim) This constructor constructs string tokenizers for the specified string StringTokenizer(String str, String delim, boolean returnDelims) This constructopr constructs a string tyokenizer for the specified string.
  • 4. Methods in StringTokenizer Method Description Int countTokens() This method calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception Boolean hasMoreElements() This method returns the same value as the hasMoreTokens method Boolean hasMoreTokens() This method tests if there are more tokens available from this tokenizer's string Object nextElement() This method returns the same value as the nextToken method, except that its declared return value is Object rather than string String nextToken() This method returns the next token from this string tokenizer String nextToken(String delim) This method returns the next token in this string tokenizer's string