Sep 26

Write a java program to find duplicate numbers in array or list?

This is one of the frequently asked interview question in interview.So lets begin writing the program by writing the pseudo code.

Pseudo Code :

1) Create a new empty hashmap.

2) This map is used to store the values and the number of times it got repeated.

3) Loop through each value in array and check whether that value is present in map or not.

4) If that value is present in map increment the count.otherwise store that value with count 1.

5) Finally loop through the map and print the values which are greater than 1 which will give you the list of duplicate values. Continue reading

Sep 25

How to remove html tags from String in java?

Remove HTML tags from String in java

This tutorial explains how to remove html tags from a string in java.For example I have a string with html tags and i want only content between tags.

String htmlString=”<head>welcome to java Interview questions website</head> “;

In the above string if we want only content by remove tags, we can use regular expressions to do the same. Continue reading