Krantik Chavan has Published 324 Articles

Export Preferences to XML file in Java

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 14:57:16

407 Views

In order to export preferences to an XML file in Java, we need to use the exportSubtree() method. This method emits an XML document showing all of the preferences contained in this node and all of its descendants. This XML document provides an offline backup of the subtree rooted at ... Read More

Perform Animation on CSS max-height

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 14:55:13

185 Views

To implement animation on max-height property with CSS, you can try to run the following code:ExampleLive Demo                    div {             width: 350px;             background-color: orange;         ... Read More

Display the amount of free memory in the Java Virtual Machine

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 14:55:03

305 Views

In order to display the amount of free memory in the Java Virtual Machine, we use the freeMemory() method. It is a method of the java.lang.Runtime Class. It returns the amount of free memory in the Java Virtual Machine. If we call the gc method, there is a possibility of ... Read More

Get number of available processors in Java

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 14:53:39

3K+ Views

In order to get the number of available processors in Java, we use the availableProcessors() method. The java.lang.Runtime.availableProcessors() method returns the number of processors which are available to the Java virtual machine. This number may vary during a particular call of the virtual machine.Declaration − The java.lang.Runtime.availableProcessors() method is declared ... Read More

Roll a six-sided die 6000 times in Java

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 14:51:04

506 Views

In order to roll a six sided die 6000 times in Java, we need to the nextInt() statement with decision making statements.The nextInt() method returns the next random integer value from this random number generator sequence.Declaration − The java.util.Random.nextInt() method is declared as follows −public int nextInt()Let us see a ... Read More

Java Program to fill elements in a long array

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 13:20:30

179 Views

Elements can be filled in a long array using the java.util.Arrays.fill() method. This method assigns the required long value to the long 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

Get array upperbound in Java Multidimensional Arrays

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 13:18:03

419 Views

In order to get the array upperbound of a multidimensional array, we use the length() method. For a 2D array, the length() method returns the number of rows. We can access the number of columns using the array_name[0].length method.Let us see a program to get the array upperbound in Java ... Read More

Create array with Array.newInstance with Java Reflection

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 13:14:40

89 Views

The java.lang.reflect.Array.newInstance(Class componentType, int length) method forms a new array with the component type and length as specified in the argumentsDeclaration − The java.lang.reflect.Array.newInstance(Class componentType, int length) method is declared as follows −public static Object newInstance(Class componentType, int length) throws IllegalArgumentException, NegativeArraySizeExceptionLet us see a program to create array with ... Read More

Get class from an object in Java

Krantik Chavan

Krantik Chavan

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

178 Views

The runtime class of an object can be obtained using the java.lang.Object.getClass(). Also, the getName() method is used to get the name of the class.A program that demonstrates getting the class of an object using the getClass() method is given as follows −Example Live Demopublic class Demo {    public static ... Read More

List the Interfaces that an Interface Extends in Java

Krantik Chavan

Krantik Chavan

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

252 Views

The interfaces that are implemented by an interface that is represented by an object can be determined using the java.lang.Class.getInterfaces() method. This method returns an array of all the interfaces that are implemented by the interface.A program that demonstrates this is given as follows −Example Live Demopackage Test; import java.lang.*; import ... Read More

Advertisements