Your code is always going into the while() loop. When your random number is not duplicate, but also when the random number is duplicate.
You did not put a condition around while loop to prevent that it is executed on duplicates.
And if you detect a duplicate, you search for a new random number, and add it without checking if it is a duplicate (after System.out.println(r1+" Already present"); ) This might be a duplicate again.
And your while loops keeps on going, even if you have found the matching record.
hey i still havent got a resolution of the duplicate entries, when my condition goes inside the else loop it should check with the array, if if has the value present or not,but it is not checking the condition, any suggestions
when my condition goes inside the else loop it should check with the array, if if has the value present or not,but it is not checking the condition
Your else loop does not do that. It adds something to the array. It does not check the array.
You might not find the solution by looking at the code (speaking from my own experience) .
Take a fresh start and a deep breath. Go back to the drawing board and re-invent the logic.
Keep it as simple as you can.
Then code it as simply as you can.