coderz.py

Keep Coding Keep Cheering!

StringTokenizer in Java

A string can be divided into tokens using Java’s StringTokenizer class.  Internally, a StringTokenizer object keeps track of where it is in the string that has to be tokenized.  Some procedures move this place ahead of the currently processed characters.  By extracting a substring from the string that was used to generate the StringTokenizer object, a token is returned.  It offers the initial stage of the parsing procedure, often known as the lexer or scanner.  The String Tokenizer class enables applications to tokenize strings. The Enumeration interface is implemented by it.  Data parsing is done using this class.  We must specify an input string and a string with delimiters  to use the String Tokenizer class  The characters that divide tokens are known as delimiters. The delimiter string’s characters are all accepted as delimiters. Whitespaces, new lines, spaces, and tabs are the default delimiters. Constructors of StringToken:  Let us consider ‘str’ as the string to be tokenized StringTokenizer(String str): Delimiters that are typically used include newline, space, tab, carriage return, and form […]

June 18, 2022 | Java | No comments

Java StringBuffer class

StringBuffer is a String peer class that provides a lot of the same functionality as strings. StringBuffer represents growable and writable character sequences, whereas a string represents fixed-length, immutable character sequences. Characters and substrings can be inserted in the middle or appended to the end of a StringBuffer. Constructors of StringBuffer class : 1. StringBuffer(): It saves […]

June 16, 2022 | Java | No comments

Advertisement