Category: Java tutorial
-
Array.prototype.splice() method
1. Overview The splice() method modifies an array directly by adding, removing, or replacing elements at specific positions. The splice() method is a mutating method. It may change the content of this. If the specified number of elements to insert differs from the number of elements being removed, the array’s length will be changed as…
-
A06:2021 – Vulnerable and Outdated Components
1. Overview The Vulnerable and Outdated Components category highlights risks associated with using software components, libraries, frameworks, or dependencies with known vulnerabilities or outdated versions. Modern applications often rely heavily on third-party components, which, if not properly managed, can expose systems to serious security risks. 2. Description You are likely vulnerable: 3. How to Prevent…
-
A02:2021 – Cryptographic Failures
1. Overview A02:2021 – Cryptographic Failures is one of the security risks identified in the OWASP Top 10 for 2021. It highlights vulnerabilities caused by improper implementation, use, or management of cryptographic systems in applications. Cryptographic failures occur when sensitive data is inadequately protected. This category was previously called “Sensitive Data Exposure” but was renamed…
-
Handling time zones in distributed systems
1. Introduction Managing dates and times in applications is a frequent but complex challenge that demands careful design and implementation to ensure accuracy. This complexity increases when applications cater to users worldwide, each operating in different time zones. Additionally, many countries—or even specific regions within them—observe Daylight Saving Time (DST), adding another layer of intricacy…
-
‘this’ keyword in JavaScript
1. Introduction The this keyword is one of the most perplexing concepts in JavaScript. The confusion arises from the fact that its value is determined differently depending on the context in which it is used. The this keyword can be used in different contexts: inside functions, global scope, inside modules, etc. 2. Function context The…
-
Collectors partitioningBy() method in Java
1. Introduction In Java, the Collectors class provides various methods to collect data from streams. One of the most powerful and frequently used methods is Collectors.partitioningBy(). This method is used to partition a stream of elements into two groups based on a given predicate. It returns a Map with Boolean keys (true and false) and…
-
Virtual threads in Java – An Introduction
1. Introduction In this tutorial, we’ll discuss virtual threads. 2. Motivation Behind virtual threads Server applications typically manage concurrent user requests that operate independently. Therefore, it is logical for an application to handle each request by assigning a dedicated thread for its entire duration. This thread-per-request approach is straightforward to understand, program, debug, and profile…
-
Java switch expressions
1. Introduction There were two problems of switch statements: default control flow behavior of switch blocks and the default scoping of switch blocks. To solves these issues, switch expression was introduced. Switch expression was a preview language feature in JDK 12 and JDK 13. With switch expressions switch was extended to be used either a…
-
Record classes in Java
1. Introduction Many developers believe that the Java is too verbose. Writing a simple data-carrier immutable class involves a lot of low-value code such as constructors, accessors, equals, hashCode, toString etc. For example, a class Point representing a point in two dimensional space with two coordinates x and y can be written like this: Here,…
-
Sealed classes in Java
1. Introduction In this tutorial, we’ll discuss a very important introduction in Java language, sealed classes and interfaces. The enums in Java assist in modeling fixed set of values. But sometimes we need to model fixed kind of values. For example, Here, there are three types of Vehicle. To restrict the kind of Vehicle, we…