We are using the HashMap to store the character as key and count
of times it is repeated as value.
package com.string.codebyakram;
import java.util.HashMap;
public class NonReapingCahr {
public static void main(String[] args) {
String string = "hello";
System.out.println(findNonReapingCahr(string));
}
...
Showing posts with label Interview Questions. Show all posts
Showing posts with label Interview Questions. Show all posts
undefined
201
undefined
201
package com.avaya.deletelogs;
import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.List;
public class DeleteLogs {
private String baseDir = "/opt/java/IVRLog";
private int daysBack = 4;
public void invokeProcess() {
getFolders();
}
public void getFolders() {
try...
undefined
201
Lets se how we can sort the object by using java 8 lambda comparator. For this let take a Employee class.
public class Employee {
private String name;
private int salary;
// standard constructors, getters/setters, equals and hashcode
}
1. Classic sort (without lambda)
Comparator< Employee...
undefined
201
As we know, map is based on key-value pair associations, so interviewer can ask you this question if you are a beginner or having less than 3 years of experience.
So lets see how we can the key and values from a Map?
In Java we have and Map.Entry method that returns a collection-view of map.
Map< string string="">...
undefined
201
We can set the timeout for RestTemplate by doing some custom configuration for RestTemplate.
First you need to create a class named as HttpClientConfig in this class we configure HttpClient because RestTemplate internally uses the HttpClient.
package com.codebyakram;
import org.apache.http.client.config.RequestConfig;
import...