Popular Java Examples

In this serious of posts, I will list some popular java programs. They are related to Singleton Pattern,  File read and write, Java Date conversion, Java collections usage, Java HashMap usage.

1. Java Singleton example

Please refer to this post: five ways to implement Java Singleton

2. Java read file using BufferedReader


3. Java Append a String to a file


4. Convert String to Date in Java



5. Convert Java util.Date to sql.Date

This snippet shows how to convert a java util Date into a sql Date for use in databases.

6. Java Convert Byte to String

In order to convert Byte array into String format correctly, we must explicitly create a String object and assign the Byte array to it.

7. Java List for Loop 

See the post for how to loop a Java List

8. Java HashMap for loop

See this post for how to loop a java Hashmap

9. Use Java HashMap to Count Word frequency

Please refer to this post for how to count word frequency using HashMap

To be continued…