What is Stack? Stack is a linear data structure that follows the specific order to perform the operations. For example, if we want to access the element in the array we can do it any time but in the case of stack data structure, there is only one sequence to access the element. In the stack, we insert the element from one end with push operation and delete the element from the same end using pop operation. The end of the stack used to perform all the operations is called the top of the stack. Therefore, a stack follows the LIFO (Last In First Out) principle, which means the element that is inserted last will be the first element to come out of the stack. The most important thing to remember in the stack data structure is that it stores the elements of the same data type only. Let us understand the condition to check whether the stack is empty for full: Condition to Check if Stack is Empty int Empty() { if (top ==- 1 ) return 1 ; else return 0 ; } Con...
Java Reflection is a process of examining or modifying the run time behavior of a class at run time The java.lang.Class class provides many methods that can be used to get metadata, examine and change the run time behavior of a class. The java.lang and java.lang.reflect packages provide classes for java reflection The java.lang.Class class performs mainly two tasks: provides methods to get the metadata of a class at run time. provides methods to examine and change the run time behavior of a class. How to get the object of Class class? There are 3 ways to get the instance of Class class. They are as follows: forName() method of Class class getClass() method of Object class the .class syntax 1) forName() method of Class class is used to load the class dynamically. returns the instance of Class class. It should be used if you know the fully qualified name of class.This cannot be used for primitive types. Let's see the simple example of forName() meth...
Comments
Post a Comment