java.util

java.util.Scanner

The Scanner class in the java.util package is used to read input (text) from various input sources like: System.in (keyboard) Files Strings Input streams It provides parsing methods to read different types of data like int, float, double, boolean, String, etc., and is commonly used for interactive user input. Commonly Used Constructors and Methods Simple […]

java.util.Scanner Read More »

java.util.Formatter

java.util.Formatter is a utility class used to format data (like numbers, strings, etc.) into formatted strings. It behaves similarly to C-style printf formatting and is often used in combination with String.format(), PrintWriter, or directly with console output. Formatter allows precise control over string formatting, such as padding, alignment, decimal precision, and locale-specific formatting. Commonly Used

java.util.Formatter Read More »

java.util.StringTokenizer

StringTokenizer is a legacy class in the java.util package that allows you to break a string into tokens (words or parts) based on specified delimiters (e.g., comma, space, colon). It is often used for parsing text input. Although newer classes like String.split() or Scanner are recommended for modern development, StringTokenizer is still useful for simple

java.util.StringTokenizer Read More »

java.util.Locale

The Locale class represents a specific geographical, political, or cultural region. It is used to tailor data (such as date formats, number formats, or messages) to the rules and conventions of a specific region. Each Locale object consists of: A language code (like “en” for English), An optional country code (like “US” for United States),

java.util.Locale Read More »

java.util.Currency

The Currency class represents a currency as defined by the ISO 4217 standard. It provides information such as: Currency code (like “USD”) Symbol (like “$”) Default fraction digits (like 2 for cents in dollars) It’s immutable and thread-safe. Key Features One instance per currency (singleton per currency code) Supports getting currency by Locale or currency

java.util.Currency Read More »

java.util.BitSet

BitSet is a class in the java.util package that implements a vector of bits that grows as needed. Each component of the bit set has a boolean value (true for 1 and false for 0). It is useful for storing flags, manipulating binary data, or working with sets efficiently using bit-level operations. Key Features: Dynamic

java.util.BitSet Read More »

java.util.Random

The Random class is part of the java.util package and is used to generate pseudo-random numbers of different types: int, long, float, double, boolean, and Gaussian values. Based on a 48-bit seed using a linear congruential formula. Thread-safe only if externally synchronized. Can generate both bounded and unbounded values. Commonly Used Methods Simple Program: Lottery

java.util.Random Read More »

java.util.TimeZone

The java.util.TimeZone class represents a time zone offset and also figures out daylight saving time adjustments. It is used in conjunction with Calendar, Date, and the formatting classes. Commonly Used Methods Common Time Zone IDs Examples “UTC” “GMT” “Asia/Kolkata” “America/New_York” “Europe/London” For More Time Zone ID’s https://docs.oracle.com/middleware/1221/wcs/tag-ref/MISC/TimeZones.html Simple Example Problem Statement:Listing All TimeZones with GMT

java.util.TimeZone Read More »

java.util.Calendar

The java.util.Calendar class is an abstract class used to perform date and time arithmetic such as adding days, months, or retrieving specific fields (like year, month, day, etc.). It provides more functionality than java.util.Date and was introduced to overcome some limitations of the Date class. Key Features: Allows field-level manipulation (like setting specific year, month,

java.util.Calendar Read More »

Scroll to Top