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
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
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.
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
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
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; }
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
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
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.
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP