Posts

Showing posts from September, 2019

Java-Comparable and Comparator with example

Comparable Interface and Comparator Interface in java are very useful for sorting the collection of objects The Comparable Interface in Java with Example The Comparable interface has the  compareTo (T obj) method which is used by sorting methods, you can check any Wrapper, String, or Date class to confirm this. We should override this method in such a way that it returns a negative integer, zero, or a positive integer if “this” object is less than, equal to, or greater than the object passed as an argument. Comparable is present in java.lang package. We can sort the list elements of Comparable type by Collections.sort(List) method. Example: Consider an Employee class that has members like, username,userid,   year of joining. Suppose we wish to sort a list of Employees based on the year of joining. We can implement the Comparable interface with the Employee class, and we override the method compareTo() of Comparable interface.   Employee.java //A Java program to demonstrate the u

WebSocket + Spring boot simple application example

Image
Hello everyone, Today we will learn how to develop a Simple Spring Boot chat application with WebSocket Why WebSocket? We already know traditional HTTP requests are unidirectional and heavy. But WebSocket is bi-directional. The initial connection is using HTTP, then this connection gets upgraded to a socket-based connection. This single connection is then used for all future communication. The WebSocket message data exchange is much lighter compared to HTTP Following technologies stack being used: Spring Boot 2.1.4.RELEASE Spring 5.1.6.RELEASE  JDK 1.8 Eclipse Oxygen Bootstrap Thymeleaf WebSocket User Interface Project Structure Pom.xml[maven] <?xml version = "1.0" encoding = "UTF-8" ?> <project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >

Spring Boot-AngularJS-Bootstrap-JPA-CRUD

Image
Hello everyone, Today we will learn how to develop a Spring Boot CRUD application with, Angular JS, embedded Tomcat, and JPA. You can download the source code of this simple application from our GitHub repository.    More  practice: Spring Boot - Spring Security -Google OAuth2 Login - Example Registration and Login with Spring Boot + Spring Security + Thymeleaf Spring Boot-Authentication and Authorization with Spring Security & JWT Kotlin - Spring Security -Google OAuth2 Login - Example   Following technologies stack being used: Spring Boot 2.1.4.RELEASE Spring 5.1.6.RELEASE  Angular JS JDK 1.8 Eclipse Oxygen Bootstrap Thymeleaf H2DB -in-memory database   User Interface Project Structure   Pom.xml(maven) A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details utilized by Maven to build the project. It contains default values for most projects. Some of the configu