Anvi Jain has Published 569 Articles

Get the Component Type of an Array Object in Java

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 13:02:42

2K+ Views

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 ... Read More

How to work with getDeclaringClass() in Java

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:54:34

116 Views

The getDeclaringClass() method returns the Class object for the class in which the object was declared. This happens only if the Class of the Class object is a member of another class. Otherwise this method returns null.Also, if a primitive type, array class, void etc. are represented by the Class ... Read More

How to schedule tasks in Java to run for repeated fixed-rate execution, beginning at the specified time

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:33:59

2K+ Views

One of the methods the Timer class is void scheduleAtFixedRate(TimerTask task, Date firstTime, long period). This method schedules the specified task for repeated fixed-rate execution, beginning at the specified time.In fixed-rate execution, each execution is scheduled with respect to the scheduled run time of the initial execution. Fixed-rate execution is ... Read More

Prove that the interface for a primitive type is an empty array in Java

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:25:30

158 Views

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 −Example Live Demopackage Test; import java.util.*; public class Demo {    public static void main(String[] args) {       Class c = int.class; ... Read More

How to call Private Constructor in Java

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:23:27

1K+ Views

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 −Example Live Demopackage Test; import java.lang.reflect.*; ... Read More

Get the name of a primitive type in Java

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:08:55

2K+ Views

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 ... Read More

Java Program to fill elements in an int array

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:06:00

3K+ Views

Elements can be filled in an int array using the java.util.Arrays.fill() method. This method assigns the required int value to the int array in Java. The two parameters required are the array name and the value that is to be stored in the array elements.A program that demonstrates this is ... Read More

Call methods of an object using reflection in Java

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 12:05:30

770 Views

The methods of an object can be called using the java.lang.Class.getDeclaredMethods() method. This method returns an array that contains all the Method objects with public, private, protected and default access. However, the inherited methods are not included.Also, the getDeclaredMethods() method returns a zero length array if the class or interface ... Read More

Typecasting NULL to 0 in MySQL

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 11:36:05

493 Views

You can typecast NULL to 0 with the help of IFNULL() function. The syntax is as follows −select ifnull(yourColumnName) as anyVariableName from yourTableName;To understand the above concept, let us first create a table −mysql> create table TypecastDemo    −> (       −> AccountNumber int    −> ); Query ... Read More

Get the week number in MySQL for day of week?

Anvi Jain

Anvi Jain

Updated on 25-Jun-2020 11:25:15

253 Views

MySQL DAYOFWEEK() function returns 1 for Sunday, 2 for Monday and so on for day of week. Let us see an example by first creating a table −mysql> create table DayOfWeekDemo −> (    −> Issuedate datetime −> ); Query OK, 0 rows affected (0.52 sec)Inserting date in the table ... Read More

Previous 1 ... 5 6 7 8 9 ... 57 Next
Advertisements