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

180 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

Reverse Order of All Elements of ArrayList with Java Collections

Ankith Reddy
Updated on 25-Jun-2020 14:33:30

3K+ Views

In order to reverse order of all elements of ArrayList with Java Collections, we use the Collections.reverse() method.Declaration −The java.util.Collections.reverse method is declared as follows −public static void reverse(List list)Let us see a program to reverse order of all elements of ArrayList with Java Collections −Example Live Demoimport java.util.*; public class Example {    public static void main (String[] args) {       ArrayList list = new ArrayList();       list.add(1);       list.add(2);       list.add(7);       list.add(8);       list.add(3);       list.add(9);       System.out.println("Original list : " + ... Read More

Move a File from One Directory to Another in Java

George John
Updated on 25-Jun-2020 14:32:50

6K+ Views

We can use Files.move() API to move file from one directory to another. Following is the syntax of the move method.public static Path move(Path source, Path target, CopyOption... options) throws IOExceptionWheresource − Source path of file to be movedtarget − Target path of file to be movedoptions − options like REPLACE_EXISTING, ATOMIC_MOVEExampleimport java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Tester {    public static void main(String[] args) {       //move file from D:/temp/test.txt to D:/temp1/test.txt       //make sure that temp1 folder exists       moveFile("D:/temp/test.txt", "D:/temp1/test.txt");    }    private static void moveFile(String ... Read More

Shuffle Elements of ArrayList with Java Collections

George John
Updated on 25-Jun-2020 14:32:41

3K+ Views

In order to shuffle elements of ArrayList with Java Collections, we use the Collections.shuffle() method. The java.util.Collections.shuffle() method randomly permutes the list using a default source of randomness.Declaration −The java.util.Collections.shuffle() method is declared as follows −public static void shuffle(List list)Let us see a program to shuffle elements of ArrayList with Java Collections −Example Live Demoimport java.util.*; public class Example {    public static void main (String[] args) {       ArrayList list = new ArrayList();       list.add(1);       list.add(2);       list.add(7);       list.add(8);       list.add(3);       list.add(9); ... Read More

Multithreading in Java

Arjun Thakur
Updated on 25-Jun-2020 14:32:18

704 Views

Java is a multi-threaded programming language which means we can develop multi-threaded program using Java. A multi-threaded program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs.By definition, multitasking is when multiple processes share common processing resources such as a CPU. Multi-threading extends the idea of multitasking into applications where you can subdivide specific operations within a single application into individual threads. Each of the threads can run in parallel. The OS divides processing ... Read More

Swap Elements of ArrayList with Java Collections

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

10K+ Views

In order to swap elements of ArrayList with Java collections, we need to use the Collections.swap() method. It swaps the elements at the specified positions in the list.Declaration −The java.util.Collections.swap() method is declared as follows −public static void swap(List list, int i, int j)where i is the index of the first element to be swapped, j is the index of the other element to be swapped and list is the list where the swapping takes place.Let us see a program to swap elements of ArrayList with Java collections −Example Live Demoimport java.util.*; public class Example {    public static void ... Read More

Automation in Every Sector of the Indian Economy

Dev Kumar
Updated on 25-Jun-2020 14:30:01

139 Views

Automation is an integral part of the development and progression of equipment and processes that in turn, are integral parts of most of the activities that act as engines of growth across most economies around the world. There's another side to automation and that is the importance of its application in military equipment and processes. It has been seen that nations with a history of producing robust and highly efficient military equipment, are the ones that are dominating the automation industry today.The USA, Germany, Japan, France, UK, Russia, Sweden, Italy, and Canada among a few others dominate in automation excellence.The ... Read More

Set Top Right Corner Border with CSS

seetha
Updated on 25-Jun-2020 14:29:30

302 Views

Use the border-top-right radius property in CSS to set the top right radius border. You can try to run the following code to implement border-top-right-radius property −ExampleLive Demo                    #rcorner {             border-radius: 25px;             border-top-right-radius: 45px;             background: orange;             padding: 20px;             width: 400px;             height: 250px;          }                     Rounded border-top-right corner!    

Advertisements