stack / vector removeIf example
Java 8 introduces a new method available for Collection types: removeif(). It accepts a predicate which defines the condition on which the elements should be removed. It returns a...
Java 8 introduces a new method available for Collection types: removeif(). It accepts a predicate which defines the condition on which the elements should be removed. It returns a...
Assume you depend on two or objects to create a functional representation of “Add to cart” implementation. This can be achieved traditionally via: create objects of all dependencies and...
Let’s create a simple multi-threaded program where every thread increments the shared count variable 4 times. So if there are two threads, after they finish count value should be...
For your Automated testing, Page Load time can be configured with pageLoadStrategy through Selenium WebDriver. At a time When Page Loading takes too much time your automated tests can...
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import...
One can use static initialization block to catch exception like this: public class A { static final WebDriver wd; static { try { wd = new FirefoxDriver(); } catch...
package Set; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.Spliterator; public class SetsExamples { static Set initSet1() { Set set1 = new HashSet(Arrays.asList(11,12,13,14,15)); return set1; } static...
Following code snippet can be used to find the free disk space on local file system import java.io.File; public class FreediskspaceinGB { public static void main(String args) { File...
Following code snippet can be used to kill a process on windows system package practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class WindowsProcessKiller { // command used to...
package practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class freeport { public static void main(String args) { try { Runtime rt = Runtime.getRuntime(); String command = “netstat -an”;...