Print occurrence of integer in java

Solution: There will be many ways to solve this problem, but here we are giving two solutions to print occurrence of integer 1) Printing occurrence of integer using Collections.freequence() method 2) Printing occurrence of integer using HashMap

Output

 

Reverse a string in java with or without using StringBuilder api

Solution:  In this program there are 3 solutions  1) Reverse string using StringBuilder API 2) Reverse string by reading from end of the string 3) Reverse string by using Recursion

Output

 

Write a program to generate a random integer in a specified range

Solution

Output

 

Find the Missing Number in array

You are given a list of n-1 numbers and these numbers are in the range of 1 to n. There are no duplicates in list. One of the number is missing in the list. Write a program to find the missing number. Example:

Solution:

Output

 

How to find maximum and minimum value from an array

 Output

 

How to generate Random passwords using java.util.Random API?

in this example we will see sample program to  generate Random passwords using java.util.Random API

Output

 

How to pretty print XML from Java?

I have an xml which is non-format as below. How i can make it nicely formatted xml.

Pass the books.xml in the below program , run the program and see output.

Output: Now we can see that books.xml is printed in nice format.

 

How to Read/Parse CSV file in Java

In this tutorial we can learn how to parse the content from CSV file in Java. There some other APIs also there which used to parse the content from CSV file but here we are using plain Java. Have a look into the below sample program.

  Here is the CSV file contents:   […]