120 likes | 129 Views
Java is a most popular, robust, secure, platform independent and multithreading based high level programming language, because of this it is preferably used by many programmers
E N D
Index • What is class in java? • How to use class in java?
Java.long.Class is one of the most important classes in java, but mostly overlooked by Java developers. • It is very useful in the sense that it provides several helper methods, such as getClass (), forName() , which you can use to find and load a class. • Exltechis providing best Java training course in pune.
It also provides methods like class.newInstance () is the backbone of reflection and allows you to create an instance of a class without a new () operator. • The class has no public constructor, and its instance is created by JVM when a class is loaded. The class class object is also used to represent classes, enum, interfaces, and annotations in a running Java application. • The primitive types such as byte, short, char, int, float, double, and boolean are also represented by class instances.
You can use class literals, such as int, to use the appropriate class instance. • Great float.Class, or boolean.Class. It is also used to represent an instance of the array in Java. • Each array with the same type and dimension shares the same instance of the class class.
Another use of java.long.Class implements the equals () method to check whether two objects are of the same type or not. • Java.long.Class class in Java • Each time JVM creates an object, it also creates a java.long.Class object that describes the type of object. All instances of the same class share the same class object and you can obtain the class object by calling the object's getClass () method. By the way, this method is inherited from java.long.Object class.
Example of Class • For example, suppose you create two instances of the class named Person Z. • Person • A = new Person(); • Person B = new Person(); • if (A. getClass () = = B. getClass()){ • System.from.println ("A and B are instances of the same class"); • }else{ • System.from.println ("A and B are instances of different classes"); • } • In this case," A and B are instances of the same class " is printed because they are both instances of the Person class.
We need forName() and newInstance () because we often know the name of the class to instantiate while writing code,we can get it from config files, database, network or from any upstream Java or C++ application. • https://www.exltech.in/java-training.html
This is what we have called the reflective way of creating an object that is one of the most powerful features of Java and makes room for many frameworks ,such as Spring, Struts, which use Java reflection. • The object-oriented design principles are the core of OOP programming, but I have seen that most Java programmers hunt for design patterns such as Singleton pattern, Decorator pattern or Observer pattern and do not pay enough attention to Object-Oriented Analysis and design.
To do my part, I have written down all the important object-oriented design principles and set it here for a quick reference. They give you at least an idea of what they are and what benefit they offer. • I don't have examples, only the article short, but you can find a lot of examples for these design principles in my blog, just use the search box at the top of the page.
Read more: • https://www.exltech.in/