Zero-Fill Auto-Incremented Id This tutorial shows how to generate zero-fill auto-incremented unique identifier in MySQL. Sometimes you may need to generate such keys which are used in some part of the application for business logic. Below example shows how to generate zero-fill auto-incremented id in MySQL table.

Posted in MySQL

Generate Zero-Fill Auto-Incremented Id In MySQL

This tutorial shows how to select items randomly from each category in MySQL. So here I will select exactly one item randomly from each category. People who need sometimes to select photo from each photo category and display them on the page for animation purpose will be benefited. In this example I have used two…

Posted in MySQL

Select only one random item from each category in MySQL

This tutorial shows how to replace the characters in a string or text using regular expression in MySQL function. There is no built-in function available to replace any character in a string or text in MySQL so here I am creating a custom function.

Posted in MySQL

Custom regex function to replace characters in MySQL

Private Constructor You probably know that you cannot make any object if the Class contains private constructor but this is not true until a special care is taken to the private constructor. This tutorial shows an example how to create instance using Reflection even if the classes have private constructors. Though if the special care…

Posted in Java

Instantiate Object From A Class Which Contains Private constructor

This tutorial shows how to read input from keyword using Java programming language. For example if your database connection string changes then you don’t need to worry because for any database connection string like username and password, this will still work. This is a simple example, you can customize as per your need. You can…

Posted in Java

How to read input through keyboard in Java

Introduction The below example shows how to verify that a string contains only numeric value in Java. String may contain float value, double value etc. This example uses regular expression to check a string contains only numeric values. It makes sure that your string should contain only digits and dot(.). You may need sometimes to…

Posted in Java

Verify A String Contains Only Numeric Value Using Java

Introduction This tutorial shows how to merge multiple csv files into one in Java. You may need to merge multiple csv files into one in some situations for your business requirements. Suppose there are n number of csv files and each csv file is having different number of headers, so this example will show you…

Posted in Java

How to merge Multiple CSV Files into One in Java

Introduction The marker interface pattern is a design pattern that provide run-time type information about objects. It provides a means to associate metadata with a class when there is no explicit support for such metadata. The marker interface in Java does not have any method inside it, in other words, a marker interface in Java…

Posted in Java

Marker Interface example in Java

The Externalizable interface provides the necessary means for implementing a custom serialization mechanism. Implementing the Externalizable interface means that we must override writeExternal() and readExternal() methods. These methods will be called when you serialize or deserialize a particular instance or object. The difference between Serialization and Externalization is that when we implement the Serializable interface…

Posted in Java

Externalization example in Java

Introduction We will see here an example on simple log4j configuration in Java. The purpose of inserting log statements into the code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications.

Posted in Java Log4J

Simple Log4j Configuration in Java

Introduction Here you will see how ThreadLocal works in Java. Java ThreadLocal class is used to create thread-local variables. The thread-local variable can be read and written by the same thread only. In multi-threaded environments all threads of an Object share their variables, so if the variable is not thread safe, then an inconsistent state…

Posted in Java

How ThreadLocal Works In Java

Table of Contents Introduction Prerequisites Reverse A String StringBuffer’s reverse() Method StringBuilder’s reverse() Method Writing Custom Method Using Recursion Using Java 8’s Lambda and Stream API Java main Class Testing String Reverse Source Code Introduction This tutorial will show you string reverse example in Java. You can use various ways to reverse a string in…

Posted in Java

String Reverse Example In Java