This example shows how to use the break statement in Java programming. Break itself a keyword that can be used within a block like for, while, do-while or switch statements. The significance of the break statement is to terminate the current loop and exit the block. It is mostly useful in the loops while we …
Java Dictionary Example
Dictionary class is the abstract class which is parent of any class which uses the key and value pair relationship. The classes like HashTable extends this class for their functionality. Every key and every value is an object. In any one Dictionary object, every key is associated with at most one value. As a rule, the equals method should be used …
How To Check Where The Class Loaded From
This example shows to check the path of the class loaded from. This utility would be helpful in certain cases if you want to check the class loading path when there is confusion over multiple libraries exist in the different path. To do that, the below example use the following steps: Get the Class for …
Get Methods Return Type using Reflection
In this example we shall explain with a simple example to get the methods of a class using the reflection and get the return type. You can list the public and private methods of an object using the following steps: Get the Class instance of the class which you want to list the methods. In …
Get Super Class Name using Reflection
With this example, we shall show you how to get the super class of an object and use it using the reflection technique. Lets look at the following example and the steps provided below to understand the program. I have created Employee super class and its sub class Manager Created instance of Manager and assigned …
Java Iterable and Iterator Interface
One of the most widely used and most common API in Java is iterator for the collections. If we have the list of objects in an array or list objects, the iterator is very useful for iterating the objects without much extra coding. Here we discuss about the comparison of two key interfaces, Iterable and …
Get Modifiers of an Object using Reflection
This example demonstrates how to get the modifiers used in a class using the reflection API. One can use the getModifiers() method in the Class object to know about each modifier used in that specific class. Call isAbstract(int mod), isFinal(int mod), isInterface(int mod), isNative(int mod), isPrivate(int mod), isProtected(int mod), isPublic(int mod) and isStatic(int mod) methods to …
Get Package Name using Reflection
This example demonstrates how to get the package name using the Reflection API. With reflection we can get the details of any class or object and its methods, fields, etc. This is useful when we are doing the dynamic creation of the classes and invoking at run time. Lets look at the example program to …