AmitDiwan has Published 10744 Articles

Semaphore in Java

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:21:29

687 Views

A semaphore is used to control access to a shared resource when a process is being executed. This is done with the help of a counter. When this counter value is greater than 0, access to share resource is provided. On the other hand, if the value of counter is ... Read More

Quantifiers in Java

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:19:31

299 Views

Quantifier is a concept that allows the programmer to specify the number of occurrences of a specific type of value in the regular expression. There are different types of quantifiers, some of them include ‘?’ (Reluctant quantifier), ‘+’ (Possessive quantifier). In this post, we will see how reluctant quantifier works.ExampleFollowing ... Read More

Parent and Child classes having same data member in Java

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:16:11

12K+ Views

The parent class can hold reference to both the parent and child objects. If a parent class variable holds reference of the child class, and the value is present in both the classes, in general, the reference belongs to the parent class variable. This is due to the run-time polymorphism ... Read More

How can I check JavaScript arrays for empty strings?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:15:50

321 Views

Let’s say the following is our array with non-empty and empty values −studentDetails[2] = "Smith"; studentDetails[3] = ""; studentDetails[4] = "UK"; function arrayHasEmptyStrings(studentDetails) {    for (var index = 0; index < studentDetails.length; index++) {To check arrays for empty strings, the syntax is as follows. Set such condition for checking ... Read More

NavigableMap Interface in Java with Example

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:11:24

745 Views

NavigableMap is an extension of the SortedMap collection framework. It is used to arrange the elements in a uniform fashion. NavigableMap has different methods to iterate over the elements in the Map.ExampleFollowing is an example − Live Demoimport java.util.NavigableMap; import java.util.TreeMap; public class Demo {    public static void main(String[] args) ... Read More

How do I trigger a function when the time reaches a specific time in JavaScript?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:11:07

3K+ Views

For this, extract the time of specific date time and call the function using setTimeout(). The code is as follows −Example Live Demo Document    function timeToAlert() {       alert("The time is 9:36 AM");    } ... Read More

How to check for 'undefined' or 'null' in a JavaScript array and display only non-null values?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:08:53

525 Views

Let’s say the following is our array with non-null, null and undefined values −var firstName=["John", null, "Mike", "David", "Bob", undefined];You can check for undefined or null cases by using the following code −Examplevar firstName=["John", null, "Mike", "David", "Bob", undefined]; for(var index=0;index node demo203.js John Mike David BobRead More

How Do I Find the Largest Number in a 3D JavaScript Array?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:07:31

163 Views

Let’s say the following is our array;var theValuesIn3DArray = [75, [18, 89], [56, [97], [99]]];Use the concept of flat() within the Math.max() to get the largest number.Examplevar theValuesIn3DArray = [75, [18, 89], [56, [97], [99]]]; Array.prototype.findTheLargestNumberIn3dArray = function (){    return Math.max(...this.flat(Infinity)); } console.log("The largest number in 3D array is="); ... Read More

Implement Onclick in JavaScript and allow web browser to go back to previous page?

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:05:24

436 Views

For reaching the back page on button click, use the concept of −window.history.go(-1)Example Live Demo Document To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option ... Read More

Check for illegal number with isNaN() in JavaScript

AmitDiwan

AmitDiwan

Updated on 14-Sep-2020 09:01:18

210 Views

Following is the code −Examplefunction multiplication(firstValue, secondValue, callback) {    var res = firstValue * secondValue;    var err = isNaN(res) ? 'Something is wrong in input parameter' :    undefined;    callback(res, err); } multiplication(10, 50, function (result, error) {    console.log("The multiplication result="+result);    if (error) {   ... Read More

Advertisements