Copy Elements of One ArrayList to Another in Java

Arjun Thakur
Updated on 25-Jun-2020 14:38:08

8K+ Views

In order to copy elements of ArrayList to another ArrayList, we use the Collections.copy() method. It is used to copy all elements of a collection into another.Declaration −The java.util.Collections.copy() method is declared as follows −public static void copy(List

Find Minimum Element of ArrayList with Java Collections

Chandu yadav
Updated on 25-Jun-2020 14:37:35

4K+ Views

In order to compute minimum element of ArrayList with Java Collections, we use the Collections.min() method. The java.util.Collections.min() returns the minimum element of the given collection. All elements must be mutually comparable and implement the comparable interface. They shouldn’t throw a ClassCastException.Declaration −The Collections.min() method is declared as follows −public static T min(Collection c)where c is the collection object whose minimum is to be found.Let us see a program to find the minimum element of ArrayList with Java collections −Example Live Demoimport java.util.*; public class Example {    public static void main (String[] args) {       List list ... Read More

CSS voice-stress Speech Media Property

Sreemaha
Updated on 25-Jun-2020 14:36:59

171 Views

Add adjustments to the speech with the voice-stress property like change pitch, how much loud it is, etc.The following is the syntax:voice-stress: normal | strong | moderate | none | reducedThe following example is to implement the voice-stress speech media property:p {    voice-stress: strong; }Above, I have set strong emphasis using the strong voice-stress property value.

Get Enumeration Over ArrayList with Java Collections

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

601 Views

In order to get enumeration over ArrayList with Java Collections, we use the java.util.Collections.enumeration() method.Declaration −The java.util.Collections.enumeration() method is declared is as follows −public static Enumeration enumeration(Collection c)where c is the collection object for which an enumeration is returnedLet us see a program to get enumeration over ArrayList −Example Live Demoimport java.util.*; public class Example {    public static void main (String[] args) {       ArrayList list = new ArrayList();       list.add(14);       list.add(2);       list.add(73);       Enumeration en = Collections.enumeration(list); // getting enumeration over ArrayList list       ... Read More

CSS voice-volume Speech Media Property

Ankith Reddy
Updated on 25-Jun-2020 14:36:15

211 Views

Adjust the relative volume level using the voice-volume CSS property.The following is the syntax:voice-volume: [x-soft | soft | medium | loud | x-loud]The following is a code snippet for the voice-volume speech media property:p {    voice-volume: soft; }You can also set the volume in decibalsp {    voice-volume: 2dB; }Set both the voice-volume media property and volume level in decibals :p {    voice-volume: medium 3dB; }

Compare Two Short Arrays in a Single Line in Java

Ankith Reddy
Updated on 25-Jun-2020 14:36:14

326 Views

Two short arrays can be compared in Java using the java.util.Arrays.equals() method. This method returns true if the arrays are equal and false otherwise. The two arrays are equal if they contain the same number of elements in the same order.A program that compares two short arrays using the Arrays.equals() method is given as follows −Example Live Demoimport java.util.Arrays; public class Demo {    public static void main(String[] argv) throws Exception {       boolean flag = Arrays.equals(new short[] { 2, 8, 5 }, new short[] { 2, 8, 5 });       System.out.println("The two short arrays are equal? ... Read More

Perform Binary Search on ArrayList with Java Collections

George John
Updated on 25-Jun-2020 14:35:34

1K+ Views

In order to perform Binary Search on ArrayList with Java Collections, we use the Collections.binarySearch() method.Declaration −The java.util.Collections.binarySearch() method is declared as follows −public static int binarySearch(List list, T key)The above method returns the position of the key in the list sorted in ascending order. If we use a Comparator c to sort the list, the binarySearch() method will be declared as follows −public static int binarySearch(List list, T key, Comparator c)If key is not present, the it returns ((insertion point) + 1) *(-1).Let us see a program to perform binarySearch() on ArrayList −Example Live Demoimport java.util.*; public class Example { ... Read More

Replace All Elements of ArrayList with Java Collections

Chandu yadav
Updated on 25-Jun-2020 14:34:55

2K+ Views

In order to replace all elements of ArrayList with Java Collections, we use the Collections.fill() method. The static void fill(List list, Object element) method replaces all elements in the list with the specified element in the argument.Declaration −The java.util.Collections.fill() method is declared as follows −public static void fill(List

Perform Animation on CSS Opacity

vanithasree
Updated on 25-Jun-2020 14:34:54

173 Views

To implement animation on opacity property with CSS, you can try to run the following code:ExampleLive Demo                    #demo1 {             position: absolute;             top: 60px;             width: 300px;             height: 150px;             background-color: lightblue;             animation: myanim 4s infinite;          }          #demo2 {             position: absolute;             top: 90px;             left: 30px;             width: 300px;             height: 150px;             background-color: orange;             animation: myanim 3s infinite;          }          #demo3 {             position: absolute;             top: 120px;             left: 60px;             width: 350px;             height: 150px;             background-color: coral;          }          @keyframes myanim {             30% {                opacity: 0.4;             }          }                     Showing opacity       End div             Start div    

Replace All Occurrences of Specified Element in ArrayList with Java Collections

Arjun Thakur
Updated on 25-Jun-2020 14:34:24

2K+ Views

In order to replace all occurrences of specified element of ArrayList with Java Collections, we use the Collections.replaceAll() method. This method returns true if list contains one or more elements e such that (oldVal==null ? e==null : oldVal.equals(e)).Declaration −The java.util.Collections.replaceAll() is declared as follows −public static boolean replaceAll(List list, T oldVal, T newVal)where oldVal is the element value in the list to be replaced, newVal is the element value with which it is replaced and list is the list in which replacement takes place.Let us see a program to replace all occurrences of specified element of ArrayList with Java ... Read More

Advertisements