Java

Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

123

Sunday, September 27, 2015

Lambda Expressions in Java 8

Lambda Expressions: Lambda expression is an anonymous function without any declarations.  Lambda Expression are useful to write shorthand code and hence saves the effort of writing lengthy code.  It promotes developer productivity, better readable and reliable code. Lambda expressions can be converted to functional interfaces. Lambda expressions can access effectively final variables from the enclosing scope.. Syntax of Lambda...

Saturday, September 19, 2015

Difference between ServletConfig and ServletContext

In this post, we are going to see the difference between ServletConfig and ServletContext.Difference between ServletConfig and ServletContext: ServletConfigServletContext(It should have been ApplicationContext) One ServletConfig object is created per servlet One ServletContext object is created per Application Can be used to pass deployment time information to the Servlet. Information is stored as parameters in the deployment descriptor(web.xml) Can be used to share Application level information across servlets and is this information is also...

Remove duplicate record in table

In this post, we are going to see how to remove duplicate records from table.Create a test tablemysql> CREATE TABLE test_table (`id` int(11) DEFAULT NULL,`name` varchar(10) DEFAULT NULL);Insert duplicate values in test table.mysql> insert into test_table values (1,'aaa'),(1,'aaa'),(1,'aaa'),(1,'bbb'),(1,'bbb'),(1,'bbb');mysql> select * from test_table;+------+------+| id | name |+------+------+| 1 | aaa || 1 | aaa || 1 | aaa || 1 | bbb || 1 | bbb || 1 | bbb |+------+------+Remove duplicate rows from test tablemysql> alter IGNORE table...

Friday, September 11, 2015

Write a Java program to get unique characters from String

In this post, we are going to see how to get unique characters from string. There are several ways to get unique characters from string. In this post, i have implemented two ways. 1. using boolean array. 2. using map. 1. Using Boolean array: In this technique, first we need to convert string into char array. After that we need to iterate all characters. While iterating we need to check that character is already added to array or not. If it is not added then we need to add that character to boolean array and append that character to stringbuilder....

Saturday, September 5, 2015

Spring 4 MVC + Hibernate 4 + MySQL 5 + Maven 3 integration : CRUD operations example

In this post, we are going to learn how to integrate Spring4 MVC with Hibernate4 application with Maven build tool and will perform CRUD operations using MySql Database.Project Structure:The following screenshot shows final structure of the project:Tools and Technologies:Spring 4.1.5 RELEASEHibernate 4.3.8 FinalMySQL 5.1.10Java 8EclipseTomcat 8Maven 3Step 1: Create Database TableFor this demo, i have created a Employees table in MySQL database. Find...