Skip to main content

Posts

Java RoadMap

 

What does :: mean in Java?

The :: operator refers to a method reference.   A method reference is a simplified way of writing a lambda expression in order to call a method. Method references allow you to call a method by mentioning its name. The syntax for a method reference is as follows: COPY Object :: methodName There are  four  ways to use a method reference: A method reference to a static method. A method reference to an instance method of an object. A method reference to instance methods of an arbitrary object of a particular type. A method reference to a constructor. METHOD REFERENCE TO A STATIC METHOD Let's take a look at the code snippet below: COPY import java.util.function.BiFunction; class Maths { public static int printAddition( int x, int y){ return x + y; } } public class Main { public static void main( String [] args) { BiFunction< Integer , Integer , Integer > addition = Maths::printAddition; int result = addition.apply(...

Coding Standards In Java

 Coding Standards for Components : It is recommended to write components name by its purpose. This approach improves the readability and maintainability of code. Coding Standards for Classes : Usually class name should be noun starting with uppercase letter. If it contains multiple word than every inner word should start with uppercase. Eg: String, StringBuffer, Dog Coding Standards for Interface : Usually interface name should be adjective starting with uppercase letter. If it contains multiple word than every inner word should start with uppercase. Eg: Runnable, Serializable, Comparable Coding Standards for Methods : Usually method name should either be verb or verb noun combination starting with lower letter. If it contains multiple word than every inner word should start with uppercase. Eg: print(), sleep(), setSalary() Coding Standards for Variables : Usually variable name should be noun starting with lowercase letter. If it contains multiple word than every inner word should ...

What are the best opportunities for java in 2021?

Firstly, Java is widely used for building enterprise-scale web applications. Java is known to be extremely stable and so, many large enterprises have adopted it. If you are looking for a development based job at a large organization, Java is the language that you should learn. It is widely used in Android App Development. So if anyone is willing to find a career in Android App Development, he/she should have an intermediate level of experience in Java. Some of the different domains where Java is used widely are as follows: Financial services:  It is used in server-side applications. Big Data:  Hadoop MapReduce framework is written using Java. Banking:  To deal with transaction management. Stock market:  To write algorithms as to which company they should invest in. Retail:  Billing applications that you see in a store/restaurant are completely written in Java. Android:  Applications are either written in Java or use Java API. Scientific and Research Communi...

What is a DTO in spring Boot?

DTO, which stands for Data Transfer Object, is a design pattern conceived to reduce the number of calls when working with remote interfaces.the main reason for using a Data Transfer Object is to batch up what would be multiple remote calls into a single one. For example, lets say that we were communicating with a RESTful API that exposes our banking account data. In this situation, instead of issuing multiple requests to check the current status and latest transactions of our account, the bank could expose an endpoint that returned a DTO summarizing everything. As one of the most expensive operations in remote applications is the round-trip time between the client and the server, this coarse-grained interface can help improving performance by a great deal. ModelMapper Introduction To avoid having to write cumbersome/boilerplate code to map DTOs into entities and vice-versa, we are going to use a library called ModelMapper. The goal of ModelMapper is to make object mapping easy by ...

Project Lombok is New Feature or plugin

Project Lombok is a Java library tool that generates code for minimizing boilerplate code. The library replaces boilerplate code with easy-to-use annotations. For example, by adding a couple of annotations, you can get rid of code clutters, such as getters and setters methods, constructors, hashcode, equals, and toString methods, and so on. We have written a lot of boilerplate code such as getter, setter, equals, hashCode methods etc. in Java for years. In some cases, this causes problems in subjects like clean and readable code. For such situations, Project Lombok saves our eyes  . Also, you will be able to spend more time on the business logic using Lombok. “Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.” Project Lombok uses annotations to avoid boilerplate code. In the best cases, only five lines can replace hundreds of lines of code. @Data @AllArgsConstructor...