Fendadis John has Published 72 Articles

Change Thread Priority in Java

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:24

730 Views

A thread can be created by implementing the Runnable interface and overriding the run() method. Then a Thread object can be created and the start() method called.The thread priority determines when the processor is provided to the thread as well as other resources. It can be changed using the method ... Read More

A greedy qualifier in Java Regular Expressions

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:24

223 Views

A greedy qualifier repeats the specified token as many times as possible and then the engine backtracks and the greedy qualifier gives up matches to eventually find the required match.The regex "(\w+)(\d)(\w+)" is used to find the match in the string "EarthHas1Moon".A program that demonstrates this is given as follows:Example Live ... Read More

Use find() to find a subsequence in Java Regexp

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:24

86 Views

The find() method finds the subsequence in an input sequence that matches the pattern required. This method is available in the Matcher class that is available in the java.util.regex packageA program that uses the find() method to find a subsequence in Java is given as follows:Example Live Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; ... Read More

How to find the subsequence in an input sequence that matches the pattern required in Java Regular Expressions?

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:24

490 Views

The find() method finds the subsequence in an input sequence that matches the pattern required. This method is available in the Matcher class that is available in the java.util.regex package.A program that demonstrates the method Matcher.find() in Java regular expressions is given as follows:Example Live Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class ... Read More

Name validation using Java Regular Expressions

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:24

1K+ Views

The name can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the name and the given input name and returns true if they match and false otherwise.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    public static void main(String args[]) ... Read More

Sorting collection of String and StringBuffer in Java

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:23

861 Views

In order to sort in Java as we know we can use either Comparable or Comparator interfaces in which we could also define our custom logic to sort.One of the approach to sort is to add the entity in TreeSet or TreeMap which would sort the entries as internally they ... Read More

Streams in Java

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:23

1K+ Views

Stream is a new abstract layer introduced in Java 8. Using stream, you can process data in a declarative way similar to SQL statements. For example, consider the following SQL statement. SELECT max(salary), employee_id, employee_name FROM Employee The above SQL expression automatically returns the maximum salaried employee's details, ... Read More

How to make an object eligible for garbage collection in Java?

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:23

240 Views

Java Garbage collector tracks the live object and objects which are no more need are marked for garbage collection. It relieves developers to think of memory allocation/deallocation issues. JVM uses the heap, for dynamic allocation. In most of the cases, the operating systems allocate the heap in advance which is ... Read More

Functional Interfaces in Java Programming

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:23

463 Views

Functional interfaces have a single functionality to exhibit. For example, a Comparable interface with a single method 'compareTo' is used for comparison purpose. Java 8 has defined a lot of functional interfaces to be used extensively in lambda expressions. Following is the list of functional interfaces defined in java.util.Function package. ... Read More

How do I view events fired on an element in Chrome?

Fendadis John

Fendadis John

Updated on 30-Jul-2019 22:30:22

16K+ Views

To view events fired on an element, follow the below steps in Google Chrome:Open Google Chrome and press F12 to open Dev Tools.Now go to Sources TabGo to Event Listener Breakpoints, on the right:Click on the events and interact with the target element.If the event will fire, then you will get ... Read More

Advertisements