Throws in exception handling in java

Throws keyword in java is used to declare exceptions that can be thrown by the method. Throws keyword can be used to throw multiple exception. syntax: 1. Throws single exception [crayon-69d85c2eb4f

Read More →

How to Throw exception in java

Exceptions in java can be thrown using the “throw” keyword. The throw statements requires a object to throw. This object needs to be a throwable object. Syntax: [crayon-69d85c2eb57d6519

Read More →

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.

Params : f

Read More →

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

Read More →

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

Read More →

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

Read More →