I’ve written about Java regular expression to validate email addresses before. Today I am sharing another Java regex to validate Gmail address. It is quite simple and self-explanatory.
Following simple Java program shows how to read input values and then print smallest and largest values. It reads the input from standard input using Scanner and then uses methods from Math class to determine the largest and smallest numbers entered by the user.
Although Java’s Arrays class has a built-in method to sort an array, it is important for good Java developers to know how to sort an array on their own. Bubble sort is the simplest sorting algorithm.
Here is a list of 10 commonly used Eclipse shortcuts for Java developers. Ctrl + Shift + T: Open a type (e.g.; a class, an interface) without browsing through list of packages Ctrl + Shift + R: Open any file quickly without browsing for it in the Package Explorer Ctrl + O: Go directly to […]
Recently a reader contacted me with a question about sorting numbers in Java. After sorting the number the program then needs to print the largest and smallest values. I have written a post earlier that shows one way of finding largest and smallest numbers. That approach used Arrays but the reader wanted to find largest […]
Many Java beginners find it difficult to differentiate between == operator and the “equals()” method when comparing String variables in Java. They assume that both operations perform the same function and either one can be used to compare two string variables. I have even seen many experienced programmers committing the mistake of using “==” to […]
Today, I will share a very basic Java program that converts an ArrayList to an array. For most Java developers this is a routine task, but many newcomers to Java have asked me this question of how to convert an array to ArrayList. Here is the example code.
My earlier post on how to validate email address, SSN and phone number validation using Java regex still attracts a lot of visitors. Today I realized that another piece of data that many programmers need to validate is the date. Many Java applications have to process input date values, so I thought it will be […]
One of most visited posts on this blog is How to read properties file in Java. In that post I explained how you can read from a properties file. But many people came to that post searching for an example on how to write to a properties file. So I thought it will be beneficial […]
An example on how to validate if a String variable in Java has all numeric digits.