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.  

5 Best Free Courses to learn Vue.js for Beginners in 2024 [UPDATED]

Hello guys, If you are self-teaching Vuejs yourself or want to learn Vue.js and looking for free online courses to start with, then you have come to the right place. In the past, I have shared free courses to learn Reactjs, Angular, HTML, JavaScript, and TypeScript, and today, I am going to share the best free online courses to learn Vuejs in 2024. It’s tough competition these days, and we need to get the right kind of skills from the best resources possible. When it comes to front-end development, while Reactjs and Angular are still king and queen, vue.js quickly makes its way up to fill the gap.

Top 5 Udemy Python Courses for Beginners in 2024 - Best of Lot

Hello guys,  Python is one of the most popular programming language used in a wide range of industries, from web development to data science. As we approach 2024, there is a high demand for Python developers. If you're looking to break into the cutting edge industries like Data Science, Machine Learning, AI and Large Language Model (LLM) Development or advance your career, taking a Python course on Udemy is a great way to get started. In the past, I have shared best  free Python coursesbest Python certifications, projects, frameworks, adn a complete Python developer roadmap and In this article, I am going to share top 5 Python Udemy courses for beginners to learn Python in 2023. 

How to find length/size of ArrayList in Java? Example

You can use the size() method of java.util.ArrayList to find the length or size of ArrayList in Java. The size() method returns an integer equal to a number of elements present in the array list. It's different than the length of the array which is backing the ArrayList, which is called the capacity of ArrayList. When you create an object of ArrayList in Java without specifying a capacity, it is created with a default capacity which is 10. Since ArrayList is a growable array, it automatically resizes when the size (number of elements in the array list) grows beyond a threshold. 

How to remove all elements of ArrayList in Java - RemoveAll Example

There are two ways to remove all elements of an ArrayList in Java, either by using clear() or by using the removeAll() method. Both methods are defined in the java.util.List and java.util.Collection interface, hence they are available not just to ArrayList but also to Vector or LinkedList, etc. Both elements remove all objects from ArrayList but there is a subtle difference in how they do. The clear() method is straightforward, it traverses through the ArrayList and sets all indices to null, which means the ArrayList becomes empty and all elements become eligible to Garbage collection, provided there are no more references to them.

How to loop over a TreeSet in Java with Example

In our earlier articles, we have learned how to loop over ArrayList in Java and you can use the same logic to loop over a TreeSet. You can use both, enhanced for loop and Iterator to traverse over TreeSet in Java. Though worth noting is that Iterator returned by the iterator() method of TreeSet returns elements in the sorted order which is imposed by the Comparator you have provided to TreeSet at the time of instantiation. By default, if you don't provide any custom Comparator then TreeSet sorts elements in their natural order like String elements are sorted in alphabetical order and Integer elements are sorted in numeric order. When you iterate over a TreeSet the iterator follows this order.

How to Convert Vector to Array in Java? 2 Examples

In the last article, we have learned how to convert a LinkedList to an array in Java, and in today's tutorial, you will learn how to convert a Vector to an array in Java. There is a similarity between Vector and LinkedList, both implement the List interface. Even though Vector is a legacy class and exists in Java from JDK 1.1 long before the Java Collection framework was introduced, it was later retrofitted to implement the List interface. You can use the same toArray() method to convert a Vector to an array in Java. 

How to sort a LinkedList in Java? Example Tutorial

Since LinkedList implements the java.util.List interface, you can sort the LinkedList by using the Collections.sort() method, just like you sort an ArrayList. Since the LinkedList class implements the linked list data structure which doesn't provide random access based upon the index, sorting is quite expensive. In order to access any element, you need to first traverse through that element which is the O(n) operator. This method uses an efficient strategy to handle this scenario. It first copies the contents of LinkedList to an array, sorts the array, and copies it back.