Browsed by
Tag: java

Convert String to int in java

Convert String to int in java

String and Integer are one of the most use classes in java programming. Developers often have to convert String to Integer and vice-versa while interacting with different APIs. Java provides auto boxing features to convert primitive data type to corresponding classes like int to Integer, double to Double and so on, However, developers need to write their own logic or use third party APIs to convert String to int.

Read More Read More

Get keys from HashMap in Java

Get keys from HashMap in Java

One of most likely situation we seek is get keys of values from HashMap. While iterating through HashMap, there might be different scenarios as how mapping of key to value is done. 

We’ll discuss and see how we can get key/s of value/s of below mentioned pattern-

  1. Key to Value: Many to One (Many keys with same value)
  2. Key to Value: One to One (Every Key has unique value)

Read More Read More

Java – Exception Handling

Java – Exception Handling

Stuff happens. The file isn’t there. The server or database is down. No matter how good a programmer you are, you can’t control everything. Things can go wrong, very wrong. When you write a risky method, you need to handle the bad things that might happens. But how do you know when a method is risky and when do you put the code to handle the exception situation?

Read More Read More