Learn how we can use escape sequence in Java

These characters can be any letters, numerals, punctuation marks and so on. The main thing when creating a string is that the entire sequence must be enclosed in quotation marks:

public class Main {
public static void main(String[] args) {
String alex = new String ("My name is Alex. I'm 20!");

But what do we do if we need to create a string that itself must contain quotation marks? For example, suppose we want to tell the world about your favorite book:

public class Main { public static void…

Logs are often known as one of the three pillars of observability. They are great for debugging code running in production. However they can also create a lot of data and noise. You want to have deep insight into your application but at the same time you only care about the information that matters. Thus logging libraries have many logging levels, e.g.

Image for post
Image for post
  • panic (5)
  • fatal (4)
  • error (3)
  • warn (2)
  • info (1)
  • debug (0)
  • trace (-1)

You specify your global logging level and all logs with this level and greater will show up. For example, if you set your global…

Quartz is an open source Java library for scheduling Jobs. It has a very rich set of features including but not limited to persistent Jobs, transactions, and clustering.

Image for post
Image for post

You can schedule Jobs to be executed at a certain time of day, or periodically at a certain interval, and much more. Quartz provides a fluent API for creating jobs and scheduling them.

Quartz Jobs can be persisted into a database, or a cache, or in-memory. This is in contrast to Spring’s built-in task scheduling API that doesn’t support persistent jobs.

In this article, you’ll learn how to schedule Jobs in spring…

The SOLID principles were first conceptualized by Robert C. Martin in his 2000 paper, Design Principles and Design Patterns. These concepts were later built upon by Michael Feathers, who introduced us to the SOLID acronym. And in the last 20 years, these 5 principles have revolutionized the world of object-oriented programming, changing the way that we write software.

Image for post
Image for post

So, what is SOLID and how does it help us write better code? Simply put, Martin’s and Feathers’ design principles encourage us to create more maintainable, understandable, and flexible software. …

Image for post
Image for post
DAO Layer

Que 1 : Why do we use DTO and DAO, and when should we use them ? If you are developing a GUI Java software to do with inserting, editing, deleting data. But you are struggling to distinguish between DTO/DAO and Model, View, Controller (MVC) Structure? Are they similar, which is better to use when interacting with database through Java GUI .

Answer :DTO is an abbreviation for Data Transfer Object, so it is used to transfer the data between classes and modules of your application.

  • DTO should only contain private fields for your data, getters, setters, and constructors.
  • DTO

What is a Thread ?

Thread is the path of execution in application. Applications can have multiple threads which are executed in parallel. In Java, threads are instances of java.lang.Thread class or subclasses which extend the Thread class. Every thread has priority (min. 1, max. 10) which is used by Thread Scheduler to determine the priority of execution. Also, a new created thread has an initial priority set from the creating thread (parent thread).

The main thread is a single non-daemon thread that is started by JVM to execute the main method. Default priority of the main thread is 5.

public static void main(String[] args)…

Let’s build the simplest Java Spring Boot application that runs as a pod in a Kubernetes cluster

Image for post
Image for post

The Project’s Structure:

├── Dockerfile
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── k8s
│ └── depl.yaml
├── settings.gradle
└── src
└── main
└── java
└── hello
├── App.java
└── HelloWorldCtrl.java

Our App.java is the entry point of the application:

The code above contains the minimal lines needed to create a Spring Boot application.

The HelloWorldCtrl.java contains a simple controller that maps the root path (“/”) and returns a greeting String:

Creating K8s Resources

In order to create a K8s deployment, we’ll need a Docker image. Let’s add the following lines to our Dockerfile:

The steps in our…

All major server side languages support concurrency (concurrent requests) using multi thread or multi process programming like Java, .Net, Ruby & PHP, etc, until Event driven model becomes popular.

Node JS uses single thread event loop model architecture to support concurrency. All incoming request handled by single thread & shared resources in node js application. In detail, The main event loop is run on single thread with all I/O operation runs on separate threads because of its non-blocking design in order to utilize the event loop.

How it work:

  1. Considering Node JS Rest Application, while creates server on specific port…

In last article, we learned how to run specific instance of Redis. Now we’ll learn further step to deploy your first docker container :

Step 5 : Persisting Data

After working with containers for a few days, Jane realises that the data stored keeps being removed when she deletes and re-creates a container. Jane needs the data to be persisted and reused when she recreates a container.

Containers are designed to be stateless. Binding directories (also known as volumes) is done using the option -v <host-dir>:<container-dir>. When a directory is mounted, the files which exist in that directory on the host can be accessed by…

In last article, we learned how to search and run specific deployed image. Now we’ll learn further step to deploy your first docker container :

Step 2 : Finding Running Containers

The launched container is running in the background, the docker ps command lists all running containers, the image used to start the container and uptime.

This command also displays the friendly name and ID that can be used to find out information about individual containers.

The command

docker inspect <friendly-name|container-id>

provides more details about a running container, such as IP address.

The command

docker logs <friendly-name|container-id>

will display messages…

Kajal Rawal

Programming isn’t about what you know; it’s about what you can figure out.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store