The introduction of Java Lang Package:
1) Java.lang package is one of the packages in Java language. In simple words, java.lang package provides classes which we can use to design the java program.
2) Java.lang package consists of some important classes and interfaces.
3) Among all the classes, Objects are the most important one because it is the root of the class hierarchy.
4) To carry out the different operations such as mathematical or representing strings, we have to use math class and String. We have to import these classes from the java.lang package and so it is very essential.
//There are some important interfaces, classes, Exceptions, and Errors in java which you can find in the hierarchy class of java.lang package. Some important classes such as//
1) Cloneable- There are methods implemented in java; and most of the times the fields, operation or function of that method can also be used in another method for getting the results. So for that cloneable interface is used to call the instances of the object
2) Runnable- If any object wishes to execute code while they are active; this interface comes into action.
Classes:1) Byte- if the user wants to declare or store the value of a byte, by using the primitive type byte the value can be wrapped in an object.
2)Boolean- In the same way, if the value needs to get stored in True or False; Boolean value. Then the primitive type boolean can wrap the value of the same and store it in an object.
3) Character- If the user wants to represent the character class, then primitive type char will wrap the value in an object.
4) Integer – For the integers; primitive type int will be used.
5) Float – For decimal type integers; primitive type float will be used.
6) Math – It is a very important class in java language as the numeric operations such as the sum of the number, elementary exponential, logs, square roots and many other are carried out by math class.
7) Throwable – Now all the errors and exceptions in the java language are stored in one superclass which is known as Throwable class, hence making it an important class.
8) Object- As already mentioned it is the most important class of all as it is the root of the hierarchy.
9) Process -Now this class helps to create a process and also returns the instances of the process so that we can control it too.
10)Runtime – This class, allows the application to interface with the environment in which the application is running.
11) StringBuffer and StringBuilder – String also represents character class. But using StringBuffer and StringBuilder class we can also use few methods like append()- helps to add two strings; delete()- helps to delete the string or replace()-helps to replace one string with another.
12) System – Give access to the JVM; Java Virtual Machine. In simple words, It provides access to system operations
1) ArthmeticException- It throws an exception when an arithmetic condition arises. For example an integer divide by zero.
2)RuntimeException – If any condition arises during the runtime or during the normal operation of java virtual machine then it throws an exception of Runtime Exception.
3) CloneNotSupportedException – As discussed earlier, the objects are used as instances if they have the same fields, functions or operations to carry out using clone interface. But if the class does not implement the method in the object class, then it will throw this type of exception.
Error:1) StackoverflowError – When an application keeps on recurring too much. Stack overflows and so the error occurs.2) ExceptionInitializerError – It throws to indicate that an exception occurred during the evaluation of initializer.
// These errors and exceptions are stored in one superclass called as Throwable class//