Number of View: 37
Write a java program to find factorial of a number in java?
Factorial of a number : For a given value n the factorial of a number is product of all natural numbers less than given value n.
Ex : n!= n * (n-1) * (n-2) *(n-3)
5!=5*4*3*2*1 Continue reading
Number of View: 135
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
Number of View: 277
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
Number of View: 329
When the data was written to disk, certain information was lost, such as the type of each value. For example, if the value
"10" is read from a file, there’s no way to tell whether it came from an
String or a
double. We have only data, not type information, on a disk.
we want to read an object from or write an object to a file or over a network connection. Java provides a concept called serialization for this purposes. Continue reading
Number of View: 320
Java 7 added a new construct called try-with-resources.
To understand try with resources we need to understand how resources are handled before java7.Before
Java 7, when we worked with a resource, such as a file, a SQL statement, etc., you had to use a finally
block and write a few lines of boilerplate code to close the resource.
Number of View: 239
Static import :
Static import is used to import static members of class or interface.To refer static members directly without using class name we use static import.
static import declarations import only
static class members. Continue reading