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

 JAVA


  Arrays.equals() vs MessageDigest.isEqual()

Both Arrays.equals() and MessageDigest.isEqual() are used to compare the equality of two arrays. They can be interchangeably in many cases. However, they do have some differences which lead to different use cases in real applications.One difference is that the arrays passed to MessageDigest.isEqual() cannot be null while it's ok for Arrays.equals().The one major difference between these two methods is that Arrays.equals() is not time-constant while MessageDigest.isEqual() is time-constant. This means that when comparing two arrays, the arrays are compared byte by byte, Arrays.equals() will ret...

19,381 0       JAVA SECURITY ARRAYS.EQUAL() MESSAGEDIGEST.ISEQUAL()


  Convert JKS to BKS using keytool

There are lots of questions(question 1, question 2) on Stackoverflow about how to convert JKS keystore to BKS keystore(a keystore format provided by BouncyCastle) using Java keytool. The reason why this conversion gets lots of questions is that BKS is not a keystore format supported by Java SE, it's a third party keystore format. To convert JSK to BKS, the BKS provider has to be downloaded first. And a few more options needs to be added when running the keytool command.The typical command to convert JKS keystore to BKS keystore should look like below :keytool -importkeystore -srckeys...

19,063 3       JAVA SECURITY JKS KEYTOOL BKS


  this keyword in Lambda expression in Java 8

Since the release of Java 8, people are excited to see a big feature added to this language which is existing in other languages for a long time -- Lambda expression. The introduction of lambda expression in Java 8 gives people an easy way or a vertical to horizontal way to solve problems. There are many posts on the Internet which shows how to use lambda expression in Java, such as Lambda Quick Start and Java 8 Lambda Expressions Tutorial with Examples. In this post, we will only focus on the this keyword in lambda expression.Unlike anonymous functions, a lambda expression can be considered a...

17,762 2       THIS LAMBDA EXPRESSION JAVA 8


  New features in Java 9

Java 9 is planned to be released in March 2017. It will be 3 years since Java 8 was released. Are you still excited about the new features introduced in Java 8 such as Lambda, new Date APIs etc? Now Java 9 is to be released and there are also quite a few fantastic new features to be introduced.Below is a list of major new features in Java 9.Modular system. Java 9 will introduce a brand new modular system to organize Java codes. The modular system will divide different packages into different modules to ensure reliable configuration and strong encapsulation. With this, you only need to shi...

17,484 4       JAVA NEW FEATURE JAVA 9


  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...

17,046 1       JAVA RESIZE HASHMAP THRESHOLD


  How to Set Spring profile With Example

Technology:  Spring Profiles provides a way to isolates the parts of application configuration, it will make available only in certain environments. It is mainly useful it wants to load spring beans based on environment configuration, for example if the operating system is windows we can load some specific spring beans, if it is other than load different spring beans. One more scenario where spring profiles widely used, like for QA environment we will use some database which is hosted locally, for UAT we will use some different host database, for production it will vary, in this scenario`...

16,641 0       SPRING APPLICATIONS PROFILE DEVELOPMENT JAVA


  Canonicalize XML in Java

XML canonicalization is often used when there is need to create digital signature to be sent to peers for verification. Since digital signature is created based on XML data, the XML data has to be canonicalized before its signature value can be calculated. Even an extra space may affect the signature value calculated, hence it must follow some rules to canonicalize the XML data so that it has a standard format. This is why W3C created specification Canonical XML Version 1.1.This specification provides the rules to format element nodes, attribute nodes and namespace nodes etc. Different pr...

16,265 0       JAVA XML JAVA SECURITY


  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,726 1       BOOLEAN INTERVIEW JAVA SIZE