SlideShare a Scribd company logo
1 of 6
Download to read offline
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

What's hot (20)

Interface in java
Interface in javaInterface in java
Interface in java
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-thread
 
Applets
AppletsApplets
Applets
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Java Strings
Java StringsJava Strings
Java Strings
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
String classes and its methods.20
String classes and its methods.20String classes and its methods.20
String classes and its methods.20
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Generic programming in java
Generic programming in javaGeneric programming in java
Generic programming in java
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Object and class
Object and classObject and class
Object and class
 
Regular Expressions in Java
Regular Expressions in JavaRegular Expressions in Java
Regular Expressions in Java
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 

Similar to StringTokenizer in java

Similar to StringTokenizer in java (20)

string tokenization
string tokenizationstring tokenization
string tokenization
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
Java scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java ScannerJava scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java Scanner
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
Java
JavaJava
Java
 
Generics
GenericsGenerics
Generics
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
 
Generics Collections
Generics CollectionsGenerics Collections
Generics Collections
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Jdk1.5 Features
Jdk1.5 FeaturesJdk1.5 Features
Jdk1.5 Features
 
Generic
GenericGeneric
Generic
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
Learning VB.NET Programming Concepts
Learning VB.NET Programming ConceptsLearning VB.NET Programming Concepts
Learning VB.NET Programming Concepts
 
package
packagepackage
package
 
String handling
String handlingString handling
String handling
 
What-is-String-in-Java.pptx
What-is-String-in-Java.pptxWhat-is-String-in-Java.pptx
What-is-String-in-Java.pptx
 
Java String
Java String Java String
Java String
 
Java
JavaJava
Java
 
LectureNotes-05-DSA
LectureNotes-05-DSALectureNotes-05-DSA
LectureNotes-05-DSA
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 

More from Muthukumaran Subramanian (20)

Struts introduction
Struts introductionStruts introduction
Struts introduction
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Overriding methods
Overriding methodsOverriding methods
Overriding methods
 
Oops (inheritance&interface)
Oops (inheritance&interface)Oops (inheritance&interface)
Oops (inheritance&interface)
 
Non access modifiers
Non access modifiersNon access modifiers
Non access modifiers
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
Garbage collection in java
Garbage collection in javaGarbage collection in java
Garbage collection in java
 
Files in java
Files in javaFiles in java
Files in java
 
Exception handling
Exception handlingException handling
Exception handling
 
Date class
Date classDate class
Date class
 
Currency class
Currency classCurrency class
Currency class
 
Timer class in java
Timer class in javaTimer class in java
Timer class in java
 
Calendar class in java
Calendar class in javaCalendar class in java
Calendar class in java
 
Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
 
intorduction to Arrays in java
intorduction to Arrays in javaintorduction to Arrays in java
intorduction to Arrays in java
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Abstract classes
Abstract classesAbstract classes
Abstract classes
 
Java introduction
Java introductionJava introduction
Java introduction
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

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