ALL
The Ultimate Guide to Implement Function Overloading in Python
IntroductionWhen it comes to function overloading, those who have learned Java should be familiar with it. One of the most common uses is logging, where different overloaded functions are called for different parameters. So, how can we implement function overloading in Python?Concept of OverloadingFunction overloading allows multiple functions with the same name to exist within the same scope, but with different parameter lists. Although many programming languages (like Java and C++) support function overloading, Python’s design philosophy does not support this feature directly.Without O...
2,631 0 PYTHON OVERLOADING JAVA GUIDE
How to make select in WinSock exceed the 64-socket limit
When doing cross-platform network programming, the only API available on Windows that corresponds to the epoll/kevent style reactor event model is select. However, it has a limitation: the number of sockets passed into select cannot exceed FD_SETSIZE, which is set to 64.Therefore, select in Java’s NIO on Windows also has the same limit. Many services ported to Windows that use the reactor model face this constraint, which often gives the impression that server programs on Windows have weaker performance.This limit is clearly insufficient for developing a high-concurrency server. So,...
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...
4,091 0 JAVA MULTITHREADING CONCURRENCY REENTRANTLOCK
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...
1,052 0 JAVA SECURITY ENCRYPTION DECRYPTION TOKENIZATION
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 ...
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...
7,886 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...
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,952 2 JAVA DESIGN PATTERN SINGLETON MULTITHREAD