Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Deep Understanding of ReentrantLock: Unlocking the Mysteries of Java Concurrent Programming

ReentrantLock introductionReentrantLock is a class in the Java concurrent package, java.util.concurrent.locks, and is an implementation of the Lock interface. As its name suggests, it is a reentrant mutual exclusion lock.A mutual exclusion lock is a synchronization tool used to protect shared resources, ensuring that only one thread can access the resource at a given time. Reentrant means that a thread can acquire the same lock multiple times without causing a deadlock.This lock provides some basic behaviors that are the same as those of the built-in synchronization mechanism. For example, a t...

2,150 0       MULTITHREADING CONCURRENCY REENTRANTLOCK JAVA


  Simplify Cloud Data Security: A Deep Dive Into Protecting Sensitive Data in Java

Featuring encryption, anonymization, hashing, and access controlNetwork security incidents occur now and then, mostly caused by data leakage. Data security has aroused widespread concern, and the community keeps working hard on approaches to simplify data security, especially in sensitive data protection.Sensitive data includes but is not limited to personally identifiable information (PII) like names, ID numbers, passport numbers, driver’s license numbers, contact information like addresses, phone numbers, account credentials like usernames, passwords, PINs, and financial information li...

789 0       TOKENIZATION DECRYPTION ENCRYPTION SECURITY JAVA


  Is Java Set ordered or not?

“Is Java Set ordered or not? ” is the most popular question asked when you interview for a Java Developer position. Many fail to answer it, and I have to admit I was one of the many.I have known the answer is “Yes and No” for a long time.No. HashSet is not ordered.Yes.TreeSet is ordered.If the interviewer continues with some follow up questions, I’m not confident that I know the answer then.Why is TreeSet ordered?Are there any other ordered Set implementations?As a growth-minded developer that always wants to improve, it is necessary to absorb some ...

3,577 0       JAVA HASHSET SORTEDSET ORDER


  Generate signed certificate from CSR in Java

In our previous tutorial, we have explained how to generate CSR which can be sent to CA for generating a signed certificate. In this tutorial, we will explain how to generate the signed certificate from CSR in Java. We will not use an actual CA but a self-signed certificate to act as a CA certificate.Since the CSR contains the subject information where a certificate needs to be generated and signed for. The key here is to extract the subject information from the CSR and then set it as the subject of the newly generated certificate.The source code can be found below which has a complete example...

6,900 10       SIGN CERTIFICATE CSR JAVA


  When will resizing be triggered in Java HashMap?

HashMap is one of the most frequently used collection types in Java, it stores key-value pairs. Ideally it expects to use hash table which expects the data access time complexity to be O(1), however, due to hash conflicts, in reality, it uses linked list or red-black tree to store data which makes the worst case time complexity to be O(logn). Although collections are using data structures like arrays and linked lists, unlike arrays, they will dynamically resize when there is not enough space to store data  It involves copying data from old array to the new array which is considered a...

16,769 1       JAVA HASHMAP RESIZE THRESHOLD


  Singleton Design Pattern in Java

Singleton is frequently used in applications where resource may be expensive to create and no instance specific state needs to be maintained. For example, when creating database connection, a singleton may be needed. Today we will share the famous Singleton design pattern in Java.1. DefinitionSingleton design pattern is a design pattern that restricts the instantiation of a class to one object. It is one of the most well-known design patterns.2. ApplicationSingleton can be used in many occasions, for example, one database can have only one connection or connection coun...

14,586 2       JAVA DESIGN PATTERN SINGLETON MULTITHREAD


  Why accessing Java HashMap may cause infinite loop in concurrent environment

HashMap in Java is frequently used to handle key/value pairs. But it is not a good candidate to be used in concurrent environment where ConcurrentHashMap should be used instead. If used in concurrent environment, it may cause lots of unexpected behavior even including make the program getting into an infinite loop situation.To understand how this can happen, let's first discuss how HaspMap works internally. In this post we will use implementation of HashMap before Java 8 as example, Java 8 provides a different version of HashMap implementation which is more efficient but more complicated as we...

8,005 0       JAVA HASHMAP INFINITE LOOP


  How many bytes a boolean value takes in Java?

Have you ever wondered how many bytes a boolean value takes in Java? One byte, this might be the answer comes out of your mind right away. But is it? Let's dig in more.Per Oracle documentation on boolean value definition, there is below statement:boolean: The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined.From the description, it mentions that the size of the boolean value is not precisely defined. This ...

15,501 1       BOOLEAN INTERVIEW JAVA SIZE