Java Blog Posts

DeDuplication-ReDuplication

This article helps you to deduplicate a string given a string and chunk size.
Case : Lets say you have a large text file. Each row contains an email id and some other information (say some product-id). Assume there are millions of rows in the file. How would you effieciently de duplicate the data ?
DeDuplication : The process that returns an intermediate strinig , helps in reduplication of original string.
Steps to follow :
1. Break the string into chunks of the given size (Values of chunk size can be 1KB,10KB and so on).
2. Find the unique chunks and make a note of where these chunks occur in the string.
3. The intermediate string should contain the unique strings and their positions.

0 Likes 5986 Views
How to install maven in terminal...?

Maven
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
This POM file contains all the dependencies which will be downloaded automatically which reduce the manual downloading.
While adding dependencies normally we can forget the dependencies when there are more than xxxx at that time maven will help you.
It contains the groupid,artifactid and version. By using these three it will download the required files automatically.
While you are trying to install maven in terminal on mac os x the steps you need to take are:
1) First we should have command line tools,These can be installed with the help of following command,

0 Likes 2199 Views
Spring Boot Application

First you create a maven project in eclipse
you can create it with the following way:
Go to New --> Other --> Select Maven Project --> Give group id and artifact id  --> Finish
Note : Both Artifact Id and Group Id should be same.
Now you can see the following structure.
Now in the pom.xml you need to add the dependencies:
//pom.xml

1 Likes 1207 Views
Connecting Postgresql with Java

This article tells you how to connect the postgresql with java program. If we connect to the postgresql we can perform operations directly from the java program without doing the operations in postgresql.
Download Postresql Driver:
To connect to the Postgresql database server from a java , you need to have a Postgresql driver.
So download the driver with this link : https://jdbc.postgresql.org/download.html
The downloaded file is a jar file. You should copy it to a specific java program which you want to connect to the Postgresql server.
Connect to the PostgreSQL database server:
You create a New Java Project and add that driver with the following manner to your project

0 Likes 2193 Views
OOPs Concept in Java

Object-Oriented Programming :
Object-Oriented Programming or OOPs refers to languages that uses objects in programming. It mainly focus on implementing real-world entities like Inheritance,hiding,Polymorphism etc in Programming.The main aim of OOPs is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
OOPSs Concepts:
Objects and Classes in Java:
An object in Java is the physical as well as a logical entity, whereas, a class in Java is a logical entity only.
An entity that has state and behavior is known as an object e.g., chair, bike, marker, pen, table, car, etc. It can be physical or logical (tangible and intangible). The example of an intangible object is the banking system.
An object has three characteristics:

1 Likes 1179 Views
Types of Inheritance in Java

Inheritance types:
On the basis of class, there can be three types of inheritance in java: single, multilevel and hierarchical.
In java programming, multiple and hybrid inheritance is supported through interface only.
Single Inheritance :
In single inheritance, subclasses inherit the features of one superclass. In image below, the class A serves as a base class for the derived class B.
Single Inheritance Example:
//SingleInheritance.java

0 Likes 1217 Views
Interfaces in Java

Interfaces :
An interface in java is a blueprint of a class. It has static constants and abstract methods.The interface in Java is a mechanism to achieve abstraction  and multiple inheritance in Java.
Like a class, an interface can have methods and variables, but the methods declared in interface are by default abstract (only method signature, no body).
To declare an interface, use interface keyword. It is used to provide total abstraction.
Interfaces specify what a class must do and not how. It is the blueprint of the class.
An Interface is about capabilities like a Player may be an interface and any class implementing Player must be able to (or must implement) move(). So it specifies a set of methods that the class has to implement.
If a class implements an interface and does not provide method bodies for all functions specified in the interface, then class must be declared abstract.

0 Likes 1341 Views
Advantage of OOPs over Procedure-oriented programming language

Advantage of OOPs over Procedure-oriented programming language:
1) OOPs makes development and maintenance easier, whereas, in a procedure-oriented programming language, it is not easy to manage if code grows as project size increases.
2) OOPs provides data hiding, whereas, in a procedure-oriented programming language, global data can be accessed from anywhere.
Data Representation in Procedure-Oriented Programming:
Data Representation in Object-Oriented Programming:
3) OOPs provides the ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.

0 Likes 2833 Views
Multiple inheritance in Java using interface

Multiple inheritance in Java using interface:
If a class implements multiple interfaces, or an interface extends multiple interfaces, it is known as multiple inheritance.
Example for Multiple Inheritance using Interface:
//Print.java
interface Prints
{
void print();

0 Likes 1167 Views
How to send HTTP request GET/POST in Java

We have several ways to connect to an API.
Those are:
Apache HttpClient 4.5.10
OkHttp 4.2.2
Java 11 HttpClient
Java 1.1 HttpURLConnection
2. Apache HttpClient :

0 Likes 1665 Views