Saturday, October 28, 2023

Java 8 Stream.filter() example Example with Null and Empty String

The filter() is a method on Stream class, which accepts a Predicate (a functional interface with a method which return boolean) and returns a stream consisting of the elements of this stream that match the given predicate. For example, if stream is obtained from a list containing "SONY", "APPLE" and "GOOGLE" and predicate is elements with length greater than 4, then filter will return another stream containing only APPLE and GOOGLE, leaving SONY out because its length is not greater than 4. Java 8 provides advanced filtering capability using lambdas and predicates. 

Saturday, October 21, 2023

10 Example of Comparator and Sorting in Java 8

The Comparator class is used to provide code or logic for comparing objects in Java, while sorting a list of objects or a collection of objects. It's close cousin of Comparable which provides natural order sorting e.g. ascending and descending orders for numbers like int, short, long or float, and lexicographic order for String i.e. the order on which words are arranged in dictionaries. The Comparators are used while sorting arrays, lists and collections. You pass logic to compare objects and sorting methods like Collections.sort() use that logic to compare elements until they are arranged in sorted order. 

Tuesday, October 10, 2023

How to Create and Extract a ZIP File in Java? Unzip Example Tutorial

In Java, you can use ZipFile class to unzip a .jar and .zip file in Java. These classes are defined in and java.util.zip package. Unfortunately there is no ZipUtil class, which provides straightforward methods to decompress zip files, but thankfully there are enough tools available in JDK to write your own method to extract zip file in Java. There are mainly two steps to unzip a zip file in Java, first, create all directories inside of the zip file, because zip archive flattens all directory and second create all file which are inside .zip file. Sinze files in .zip file is not in specific order, you need to iterate twice to perform these steps individually.

Monday, October 9, 2023

How to implement Level Order Traversal of Binary Tree in Java? Example Tutorial

Hello guys, if you have worked in Java then you know that binary tree is one of the essential data structure and quite an important one for programmers, I even mentioned that on my 10 essential data structures for programmers articles.  Binary tree related question are also quite common on coding interviews and we are going to see one today but before that, let's revise what is binary tree? Binary trees are hierarchical data structures composed of nodes, each having at most two children: a left child and a right child. Traversing a binary tree in level order involves visiting nodes level by level, starting from the root. 

Sunday, October 8, 2023

How to make Immutable class in Java? Mutable vs Immutable Objects

How I make immutable objects in Java? I've always thought that all objects are immutable, because if you change the content of an String example, it will always create you an new String object and point to that. However later I found that String is a special class and its specially designed as an Immutable class because its often cached. Obviously you cannot cache anything which is not constant and that make sense why String is Immutable in Java. But this encouraged me to learn more about Mutable and Immutable class in Java and how to create a custom Immutable class in Java.

Saturday, October 7, 2023

Why is Java Considered a Secure Programming Language?

Hello guys, Security is a paramount concern in software development, and choosing the right programming language can play a crucial role in mitigating potential vulnerabilities and threats. Java has long been celebrated for its security features and practices, making it a preferred choice for building secure applications and systems. In this article, we'll explore why Java is considered a secure programming language and examine the features and practices that contribute to its security reputation.

Friday, October 6, 2023

Top 5 JavaScript Data Structure and Algorithm Courses for Beginners to Learn in 2024 - Best of Lot

Hello guys, if you are a JavaScript developer learning Data Structure and Algorithms and looking for the best online course to learn Algorithms and Data Structure in JavaScript, then you have come to the right place. In the past, I have shared free classes to learn JavaScript and data structure Algorithmsand today, I will share the best courses to learn Data Structure and Algorithms. These courses have been created by expert instructors like Colt Steele, Andrei Neagoie, and Stephen Grider and are trusted by thousands of developers. They are also very affordable, especially the Udemy courses you can buy for just $10 on Udemy sales which happens every now and then.

Sunday, October 1, 2023

Difference between Queue and Deque in Java? Example Tutorial

Hello guys, today I am going to share another interesting question from Java interview, what is difference between Queue and Deque in Java. This question was asked to one of my reader in a recent interview with JP Morgan Mumbai and this is also a popular Java collection interview question. While he was able to answer the question, he wasn't able to convince interviewer so he asked me how to answer this question. So I am writing this post to share my answer on Queue vs Deque in Java. In the vast world of Java programming, the need to manage data efficiently often leads developers to specialized data structures. 

Top 5 Free Courses to learn jQuery for Beginners in 2024 - Best of Lot

Hello guys, if you are thinking of learning jQuery, one of the best JavaScript libraries for client-side development, and looking for some excellent free resources like books, tutorials, and online courses, then you have come to the right place. In this article, I am going to share some of the best free jQuery courses from Udemy and, Pluralsight which you can take to learn this impressive JavaScript library. In the past, I have also shared some free books and tutorials on jQuery, which complements these courses. You can also take a look at them while learning different parts of jQuery.