Iterating over a collection is a task that most developers are required to perform during their development task and most of us keep on using the same way which we have used earlier though there are many ways to do this. In this post I am going to list down all those ways. We all might be familiar with these ways. Still, keep on reading to refresh!!! First let’s initialize a list List list = Arrays.asList(new String[]{ “first”,”second”,”third”,”fourth”, “fifth” }); Now let’s begin iteration: Method 1: Using for loop for (int count = 0; count < list.size(); count++) { System.out.println("Item:: " + list.get(count)); } DetailRead More →

There may be a scenario, if we want to determine whether a string is completely numeric or not, such as we want a user to input a number and our program should multiply it by 5 and return the result. User is a human. He may mistakenly input an alphanumeric string by mistake or to check the correctness of our program. Off course, we would not like to show an exception trace to the user instead of the result. Better we check the input for its validity before processing. Below are various ways using which we may check that an input String is completely aRead More →

Suppose we want to do a task after fixed time interval such as creating a beep sound after 5 seconds or checking the connection status after every 5 seconds. This may be easily accomplished using Executor framework in java. There is a class called ScheduledThreadPoolExecutor which has the methods to perform such kind of scheduling. Let’s get down to code right away:Read More →

Loading a class more than once using java’s built in ClassLoader is not possible because: Builtin ClassLoader always checks if a class has already been loaded. If it is, it simply does nothing and returns. Hence to reload a class, you have to use your custom ClassLoader. Code to reload a class using custom ClassLoader is as follows:Read More →

Ajax Request…What? Ajax stands for Asynchronous Javascript and XML. It is a client side technology which is used for creating dynamic web pages. Its main use is in scenarios where you want to send some data from the browser to the server and / or fetch data from the server Without Page Refresh. That’s right…without page refresh.Read More →

Suppose we have more than two input boxes on which we want to apply calendar. A jQuery datepicker can be applied to an input box using: $(“#calendarField”).datepicker(); Where we have used the id of element (after “#”).Read More →