In this post we will see the exception handling using the try catch finally in java. 1. Use of Try – Catch Block A exception in java can be handled using a Try and Catch block. Lets see a sim
Return Statement in try catch and finally block
If you have a try catch finally block in java, the return statement behaves differently. You may think 1. If I have a return in try then will finally block get called? 2. What if a exception occurs
Difference String StringBuffer and StringBuilder
We will see the differences between String, StringBuffer and StringBuilder. The main differences are related to thread safe nature and performance. Difference String StringBuffer and StringBuilder
String.format java example
In this post we will see String.format java examples. Format method in String returns a formatted string using the specified format string and arguments.
1 |
public static String format(String format,Object... args) |
ArrayList clear Vs removeAll
ArrayList can be emptied or cleared using either clear or removeAll method. Both these methods differ in performance. If you see the code for both these methods you will get to know which method is
How to clear Arraylist in java
To clear ArrayList in java we have 2 ways 1. void clear() – Clears all the elements that are present in the ArrayList 2. boolean removeAll(Collection<?> c) – Remov
How to clear Hashmap in java
To clear HashMap in java we use the void clear() method from Map. Using the clear method will empty the HashMap. Lets see examples on how to clear Hashmap in java. Example : C
How to get size of HashMap
To get size of HashMap we use the int size() method provided by Map API. The size method returns the number of key/value pairs that are available in that Map. Example : Get
How to Check if value exists in HashMap
To check if Value exists in HashMap, we use the containsValue(Object key) method provided by HashMap. boolean containsValue(Object key) searches the HashMap for the given value and returns
How to Check if key exists in HashMap
To check if Key exists in HashMap, we use the containsKey(Object key) method provided by HashMap. boolean containsKey(Object key) searches the HashMap for the given key and returns boole