Here is the listing of Java programming examples on Java.Lang.
1. Java Examples Using clone( ) & Cloneable Interface
The clone( ) method generates a duplicate copy of the object on which it is called. The Cloneable interface defines no members. It is used to indicate that a class allows a bitwise copy of an object to be made. If you try to call clone( ) on a class that does not implement Cloneable, a CloneNotSupportedException is thrown. A clone is simply an exact copy of the original. Deep copy copies the content of the object. This section contains Java programs to check whether given method is clone() method or not, checks use of protected keyword in clone() method, checks given class is deep cloning or not.
Java Program to Check if a Given Method is Clone() Method
Java Program to Check the Use of Protected KeyWord in a Clone() Method
Java Program to Check if a Given Class is Deep Cloning
2. Java Examples on Heap Memory & Environment Variables
Heap Memory is mainly used to store the Java objects. Non-Heap Memory, which is used by Java to store loaded classes and other meta data. Class instance is explicitly created by the user code and automatically destroyed by garbage collection. Environment variables are global system variables accessible by all the processes running under the Operating System. Environment variables are useful to store system-wide values such as the directories to search for the PATH and the OS version. This section contains Java programs to get the free heap memory, total heap memory and maximum heap memory, get the all values of environment variables and termination of jvm explicitly.
Java Program to Get the Free Heap Memory
Java Program to Get the Total Heap Memory
Java Program to Get The Maximum Heap Memory
Java Program to Get the Value of Environment Variable
Java Program to Get All the Environment Variables
Java Program to Terminate the JVM Explicitly
3. Java Examples on Primitive Type Wrappers
Primitive wrapper classes are found in the Java API. Primitive wrapper classes are used to create an Object that needs to represent primitive types in Collection classes. Wrapper classes are part of the java.lang package, which is imported by default into all Java programs. Wrapper classes are used to convert any data type into an object. The primitive data types are not objects, they do not belong to any class, they are defined in the language itself. This section contains Java programs on conversions like primitive to wrapper, primitive to string, string to wrapper and viceversa. The other programs in this section generates random numbers between o and 10, accepting number from keyboard and convert to other number systems.
Java Program to Convert Primitive to Wrapper
Java Program to Convert Primitive to String
Java Program to Convert String to Wrapper
Java Program of Wrapper Classes to Convert the Value from Primitive to String Object
Java Program to Accept a Number from KeyBoard and Convert it Into Other Number Systems
Java Program that Generates Random Numbers Repeatedly Between 0 and ’10’ and Ensure that If the Generated Number is ‘0’ then Program gets Terminated
4. Java Examples on Class
Class can be defined as a template that describes the behavior that the object of its type support. when classes are loaded, we cannot explicitly declare a Class object. Generally, we can obtain a Class object by calling the getClass( ) method. Garbage Collection is process of reclaiming the runtime unused memory automatically. String is the most popular immutable class in Java. Once initialized its value cannot be modified. Singleton pattern helps us to keep only one instance of a class at any time. The purpose of singleton is to control object creation by keeping private constructor. Doubleton class allows to create at-most two objects. This section contains Java programs on singleton and doubleton class, garbage collector, check whether given method is a getclass() method or not, check whether given class is garbage collector or immutable class.
Java Program to Check if a Given Method is getClass() Method
Java Program to Check if a Given Class is Garbage Collector
Java Program to Check if a Given Class is Immutable Class
Java Program to Get the Object of the Runtime Class
Java Program to Define Custom Singleton Class
Java Program to Define Custom Doubleton Class
Java Program to Invoke the Garbage Collector
Java Program to Check Whether Super KeyWord Use in Super Class for Overridden Method
5. Java Examples on Object
Entity that has state and its behavior is known as an object. Object is a superclass of all other classes. java.lang.Object provides a number of methods that are common to all objects. Java Reflection is a process of examining or modifying the run time behavior of a class at run time. Byte class simply a wrapper class for the primitive type byte. It wraps the byte primitive value to an object. This section contains Java programs on creating the object without using new operator, access the reflection object, use of byte class objects, creating date class object and checks given class is object class or not.
Java Program Creating the Object Without Using New Operator
Java Program to Check if a Given Class is Object Class
Java Program to Access the Class Object Reflection Concept
Java Program to Show the Use of Byte Class Objects
Java Program to Create Date Class Object Using the Long Value
6. Java Examples on StringBuffer
StringBuffer is a peer class of String that provides functionality of strings. String represents fixed-length, immutable character sequences. You can delete characters within a StringBuffer by using the methods delete( ) and deleteCharAt( ). The deleteCharAt( ) method deletes the character at the index specified by loc. It returns the resulting StringBuffer object. Reverse the characters within a StringBuffer object using reverse( ). trimToSize() Method reduces the size of the character buffer for the invoking object to exactly fit the current contents. equals( ) can compare an enumeration constant to any other object, those two objects will only be equal if they both refer to the same constant, within the same enumeration. This section contains Java programs on deleting the data using deleteCharAt() method, reversing the string using reverse method, check whether given method is tostring() and equals() method.
Java Program to Delete the Data Using deleteCharAt() Method
Java Program to Reverse the Contect of the String Using Reverse Method
Java Program to Set the Length Using setLength Method
Java Program to Check if a Given Method is toString() Method
Java Program to Check if a Given Method is Equals() Method
Java Program to Reduce the Capacity Up to the Length Using trimToSize() Method
Java Program to Compare the Content of the String Buffer Using ContentEquals() Method
7. Java Examples on String Comparison, Searching and Modifications
String is an object that represents sequence of characters. Java String class provides a lot of methods to perform operations on string such as compare(), concat(), split(), length(), compareTo(), substring() etc. This section contains Java programs on verifying whether sting is empty or not, create the string object from byte array, split the given string, matching the string with the specified pattern, find the word in the given string, check whether the string is starting or ending with specified string.
Java Program to Access the Part of the String
Java Program to Verify String is Empty
Java Program to Create the String Object from Char or Byte Array
Java Program to Split the Occurance of the Specified Expression
Java Program to Match the String with the Specified Pattern
Java Program to Check if a Given Operators is Directly Used
Java Program to Find the Number of Occurance of “java” in the Particular String Object
Java Program to Check Whether that String is Starting or Ending With Specified String
Java Program to Reverse the String Contact Without Using Any Methods from the String Class
8. Java Examples on Memory Management & System
System class holds a collection of static methods and variables. The standard input, output, and error output of the Java run time are stored in the in, out, and err variables. currentTimeMillis( ) method returns the current time in terms of milliseconds. The arraycopy( ) method can be used to copy quickly an array of any type from one place to another. This section contains Java programs on getting the system properties, adding or replacing the property, copying the data into array, getting the avialable processors, accessing current time in miliseconds and nano seconds, changing the default references using system class.
Java Program to Get the System Properties
Java Program to Get the Property Value of Specific Property Name
Java Program to Add or Replace the Property
Java Program to Copy the Data in Array
Java Program to Get the Available Processors
Java Program to Access Current Time in MiliSecond
Java Program to Access the Current Time in Nano Second
Java Program to Change the Default References Using Method of System Class
9. Java Examples on Methods & Interface
Hashcode value is mostly used in hashing based collections like HashMap, HashSet and HashTabl. HashCode() method must be overridden in every class which overrides equals() method. Marker interface has no method. Java has built-in marker interface like Serializable, Clonable etc that are understand by JVM. This section contains Java programs on marker interface, accessing hashcode value using HashCode() method, inserting data using overloaded method, checks whether given two object have same hashcode.
Java Program to Access HashCode Value Using the HashCode() Method
Java Program to Define Custom Marker Interface
Java Program to Insert the Data in Middle Using Overloaded Method
Java Program to Check the Method is Not a Overriding and Also Given Two Object HashCode are Same
Java Program Some Methods are Defined as Final If these Method Cannot be Overridden In the SubClass
10. Java Examples on Java.lang Packages and Libraries
The package java.lang contains classes and interfaces that are essential to the Java language. Package in java can be categorized in two form, built-in package and user-defined package. There are many built-in packages such as java, lang, awt, etc. The mechanism used to integrate C code with a Java program is called the Java Native Interface. This section contains Java programs on usage of Java.lang Package, loading native implementation libraries and executing executable files.
Java Program to Illustrate Java.lang Package Usage
Java Program to Load the Native Implementation Libraries
Java Program to Execute Any Executable File