Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Anvi Jain
Page 18 of 43
Get the Component Type of an Array Object in Java
In order to get the component type of an Array Object in Java, we use the getComponentType() method. The getComponentType() method returns the Class denoting the component type of an array. If the class is not an array class this method returns null.Declaration − The java.lang.Class.getComponentType() method is declared as follows -public Class getComponentType()Let us see a program to the get the component type of an Array Object in Java -Examplepublic class Example { public static void main(String[] args) { int[] array = new int[] {1, 2, 3}; // obtain the Class of ...
Read MoreDemonstrate getting the immediate superclass information in Java
The immediate superclass information of any entity such as an object, class, primitive type, interface etc. can be obtained using the method java.lang.Class.getSuperclass().A program that demonstrates this is given as follows −Examplepackage Test; import java.lang.*; class Class1{ } class Class2 extends Class1{ } public class Demo { public static void main(String args[]) { Class1 obj1 = new Class1(); Class2 obj2 = new Class2(); Class c; c = obj2.getClass(); ...
Read MoreProve that the interface for a primitive type is an empty array in Java
The getInterfaces() method is used to prove that the interface for a primitive type is an empty array. A program that demonstrates this is given as follows −Examplepackage Test; import java.util.*; public class Demo { public static void main(String[] args) { Class c = int.class; Class[] interfaces = c.getInterfaces(); System.out.println("The Interface is: " + Arrays.asList(interfaces)); } }OutputThe Interface is: []Now let us understand the above program.The int.class is a reference to the Class object for the primitive type int. The interface for this is determined using the getInterfaces() method. ...
Read MoreHow to call Private Constructor in Java
The method java.lang.Class.getDeclaredConstructor() can be used to obtain the constructor object for the private constructor of the class. The parameter for this method is a Class object array that contains the formal parameter types of the constructor.A program that demonstrates this is given as follows −Examplepackage Test; import java.lang.reflect.*; public class Demo { String str; Double d; public Demo(String str, Double d) { this.str = str; this.d = d; } public static void main(String[] args) { try { Demo obj = new ...
Read MoreGet the name of a primitive type in Java
The getName() method is used to get the names of the entities such as primitive type, interface, class, array class, void etc. that represented by the class objects. These names are returned in the form of a string.A program that gets the name of a primitive type using getName() method is given as follows -Examplepublic class Demo { public static void main(String[] argv) throws Exception { String name1 = float.class.getName(); System.out.println(name1); String name2 = int.class.getName(); System.out.println(name2); String name3 = char.class.getName(); System.out.println(name3); ...
Read MoreAdd Red label with Bootstrap
Use .label-danger class in Bootstrap to add red colored label.You can try to run the following code to implement the .label-danger class −Example Bootstrap Example If you find any issues, click below Danger
Read MoreAdd green label (stating success) with Bootstrap
Use .label-success class in Bootstrap to add green label.You can try to run the following code to implement the .label-success class −Example Bootstrap Example Success label Success
Read MoreBootstrap .btn-success class
To set a successful action in Bootstrap, use the .btn-success class.You can try to run the following code to implement btn-success class in Bootstrap −Example Bootstrap Example Success Button
Read MoreSet small modal in Bootstrap
Use the .modal-sm class in Bootstrap to set small modal with less width.You can try to run the following code to implement the .modal-sm class −Example Bootstrap Example Examination Result × Warning If JavaScript isn't enabled in your web browser, then you may not be able to see the result. Close
Read MoreContainer for checkboxes in Bootstrap
Add checkbox to a web page with Bootstrap, using the .checkbox class in BootstrapYou can try to run the following code to set container for checkboxes −Example Bootstrap Example Programming Survey Which programming languages do you like? Java C++ C
Read More