Insertion sort The Insertion sort algorithm views the data in two halves. The left half of sorted elements and the right half of elements to be sorted. In each iteration, one element from the right half is taken and added to the left half so that the left half is still sorted. …
Continue reading Insertion sort program in javaJava Programs
This post demonstrates : – Different way of concatenating strings in Java. – concatenate strings using + operator – concatenate string using String concat() function – joining strings using StringBuffer/StringBuilder append() method – joining Strings using join() method added in JDK 8 Method 1 : Using + operator + operator can be used …
Continue reading Program for different methods of String concatenationHere are a few ways for checking for Palindrome in java. Example 1: Palindrome using StringBuffer This program demonstates testing for a Palindrome word using StringBuffer. We accept a work from keyboard(System.in) and assign it to inputString. Then we created a StringBuffer with this and reverse it. If the …
Continue reading Palindrome program in JavaFlyweight Pattern A flyweight is an object that minimizes memory use by sharing as much data as possible with other similar objects; it is a way to use objects in large numbers when a simple repeated representation would use an unacceptable amount of memory. Sample Implementation Code : Output Popular Articles …
Continue reading Flyweight Pattern Example in JavaState Pattern This pattern is used to encapsulate varying behavior for the same object based on its internal state. Sample Implementation Code : Output Popular Articles you may like : Java 8 Interview Questions RESTful CRUD operations using Jersey and Hibernate Frequently asked Java Programming Interview questions on …
Continue reading State Pattern Example in Java