Core java
- 14 July
Difference between checked and unchecked exception in java
In this post, we will see difference between checked and unchecked exception in java. It is important question regarding exceptional handling. What is Exception? Exception is unwanted situation or condition while execution of the program. If you do not handle exception correctly, it may cause program to terminate abnormally. What is checked exception? Checked exceptions […]
- 13 July
Difference between StringBuffer and StringBuilder in java
In this post, we will see difference between StringBuffer and StringBuilder in java StringBuffer vs StringBuilder Parameter StringBuffer StringBuilder Thread-safe StringBuffer is thread safe. Two threads can not call methods of StringBuffer simultaneously. StringBuilder is not thread safe, so two threads can call methods of StringBuilder simultaneously. Performance It is less performance efficient as it […]
- 11 July
Difference between CountDownLatch and CyclicBarrier in java
In this post, we will see difference between CountDownLatch and CyclicBarrier in java. Lets first see similarities among them. Both wait for specific number of threads or tasks to finish. Lets see differences between CountDownLatch and CyclicBarrier. CountDownLatch vs CyclicBarrier Parameter CountDownLatch CyclicBarrier Reuse It can not be reused once count reaches 0 It can […]
- 19 June
Can We Have Try without Catch Block in Java
In Java, it’s possible to use a try block without a catch block, but it must be followed either by a finally block or be part of a try-with-resources statement. Let’s see both cases with the help of examples: 1. try-finally Structure You can use a try block with a finally block. As you may […]
- 07 June
Daemon thread in java with example
Daemon threads are low priority background threads which provide services to user threads. It’s life depends on user threads. If no user thread is running then JVM can exit even if daemon threads are running. JVM do not wait for daemon threads to finish. Daemon threads perform background tasks such as garbage collection, finalizer etc. […]
- 03 June
How to remove non-ascii characters from a string in java
In this post, we will see how to remove non ascii character from a string in java. Sometimes, you get non-ascii characters in String and you need to remove them. We will use regular expressions to do it. Java program to remove non-ascii characters: [crayon-6743badf96c0b439916805/] When you run above program, you will get below output: […]
- 03 June
Convert HashMap to ArrayList in java
In this post, we will see how to convert HashMap to ArrayList in java. Many times, you need to store keys or values into ArrayList or Store HashMap’s Node objects in ArrayList. HashMap and ArrayList both are the most used data structure in java and both have different Hierarchy. Here are the ways to convert […]
- 03 June
How to check if String has all unique characters in java
Learn about how to check if String has all unique characters in java
- 30 May
Java ArrayList indexOf example
ArrayList‘s indexOf method is used to find out first index of object in arraylist. indexOf method takes object as argument and returns first occurrence of specified element. Methods: public int indexOf(Object o) returns index of first occurrence of element in the ArrayList. indexOf method return -1 if object is not present in the ArrayList ArrayList […]