Display Free Memory in the Java Virtual Machine

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

401 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 increase of free memory.Declaration − The java.lang.Runtime.freeMemory() method is declared as follows −public long freeMemory()Let us see a program to display the amount of free memory in the Java Virtual Machine −Example Live Demopublic class Example {    public static void main(String[] args) {       // print statement at ... Read More

Get Number of Available Processors in Java

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

6K+ 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 as follows −public int availableProcessors()Let us see a program to get the number of available processors in Java −Example Live Demopublic class Example {    public static void main(String[] args) {       // print statement at the start of the program       System.out.println("Start...");       System.out.print("Number ... Read More

Generate Random Integer Numbers in Java

Nancy Den
Updated on 25-Jun-2020 14:52:47

6K+ Views

In order to generate Random Integer Numbers in Java, we use the nextInt() method of the java.util.Random class. This 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 program to generate random integer numbers in Java −Example Live Demoimport java.util.Random; public class Example {    public static void main(String[] args) {       Random rd = new Random(); // creating Random object       System.out.println(rd.nextInt());    } }Output27100093Note - The output might vary on Online Compilers.

Generate Random Bytes in Java

Smita Kapse
Updated on 25-Jun-2020 14:52:19

8K+ Views

In order to generate random bytes in Java, we use the nextBytes() method. The java.util.Random.nextBytes() method generates random bytes and provides it to the user defined byte array.Declaration − The java.util.Random.nextBytes() method is declared as follows −public void nextBytes(byte[] bytes)where bytes is the byte array.Let us see a program to generate random bytes in Java −Example Live Demoimport java.util.Random; public class Example {    public static void main(String[] args) {       Random rd = new Random();       byte[] arr = new byte[7];       rd.nextBytes(arr);       System.out.println(arr);    } }Output[B@15db9742Note − The output might ... Read More

Roll a Six-Sided Die 6000 Times in Java

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

637 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 program to roll a six sided die 6000 times −Example Live Demoimport java.util.Random; public class Example {    public static void main(String args[]) {       Random rd = new Random(); // random number generator       int freq[] = new int[6]; // creating an array to compute frequency ... Read More

CSS voice-range Speech Media Property

Daniol Thomas
Updated on 25-Jun-2020 14:48:43

134 Views

The voice-range property in CSS is used to set the range of the speaking voice. This is the pitch range.The following is the syntax:voice-range: [[x-low | low | medium | high | x-high]]Above, set the range of pitch i.e. low, medium, high, etc.The following is an example of the voice-range property:p {    voice-range: 90Hz; }

Convert a Queue to a List in Java

Nancy Den
Updated on 25-Jun-2020 14:48:19

1K+ Views

In order to convert a Queue to a List in Java, we can create an LinkedList and pass the Queue as an argument in the parameterized constructor of an ArrayList. This can be done as follows −Queue q = new LinkedList(); List l = new ArrayList(q);The quickest way is used to LinkedList in the first place which can be used both as a List and a Queue. This can be done as follows −Queue q = new LinkedList(); List l = (List) q;Let us see a program to convert a queue to a list −Example Live Demoimport java.util.LinkedList; import java.util.List; import ... Read More

Check If String Contains Only Unicode Letters, Digits or Space in Java

Chandu yadav
Updated on 25-Jun-2020 14:47:31

913 Views

To check if a given String contains only unicode letters, digits or space, we use the isLetterOrDigit() and charAt() methods with decision making statements.The isLetterOrDigit(char ch) method determines whether the specific character (Unicode ch) is either a letter or a digit. It returns a boolean value, either true or false.Declaration −The java.lang.Character.isLetter() method is declared as follows −public static boolean isLetter(char ch)The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration −The java.lang.String.charAt() method is declared as follows −public char charAt(int index)Let us ... Read More

Perform Animation on CSS Margin Top

Arjun Thakur
Updated on 25-Jun-2020 14:46:44

1K+ Views

To implement animation on margin-top property with CSS, you can try to run the following codeExampleLive Demo                    div {             background-color: orange;             animation: myanim 4s infinite;             color: white;          }          @keyframes myanim {             30% {                margin-top: 30px;             }          }                     Heading One                This is demo text.          

Perform Animation on CSS Min Width

Chandu yadav
Updated on 25-Jun-2020 14:46:05

304 Views

To implement animation on min-width property with CSS, you can try to run the following codeExampleLive Demo                    div {             overflow: auto;             width: 50%;             background-color: blue;             color: white;             border: 1px solid black;             animation: myanim 3s infinite;          }          @keyframes myanim {             ... Read More

Advertisements