Posts

Showing posts with the label Java immutable string

Mastering Java.Lang Package: Object, String, Wrapper Classes & Key Methods Explained

Understanding Java.Lang Package: Classes, Methods & Usage The java.lang package is one of the most fundamental packages in Java, providing essential classes required for writing any Java program. It is automatically imported in every Java program, so programmers do not need an import statement to use its classes. Overview of Java.Lang Package Known as the basic package in Java. Contains the Object class, which is the parent of every Java class. Provides String, StringBuilder, StringBuffer, and wrapper classes. Supports both final and non-final classes: Final classes: String, StringBuilder, StringBuffer, wrapper classes. (Cannot be inherited) Non-final classes: Object, Number. Key Classes in Java.Lang 1. Object Class The Object class is the root of all Java classes. Some important methods include: toString(): Returns object information as a string in the format packageName.className@hexAddress. hashCode(): Converts the hexadecimal memory address to an integer memory address. equals(...