<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vipin Sharma</title>
    <description>The latest articles on DEV Community by Vipin Sharma (@vipin_sharma).</description>
    <link>https://dev.to/vipin_sharma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F342777%2F6a89a603-4665-4ffd-8798-64433eee139c.jpg</url>
      <title>DEV Community: Vipin Sharma</title>
      <link>https://dev.to/vipin_sharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vipin_sharma"/>
    <language>en</language>
    <item>
      <title>Avoid multi threading bugs using immutable Java Records</title>
      <dc:creator>Vipin Sharma</dc:creator>
      <pubDate>Sun, 13 Jun 2021 12:40:57 +0000</pubDate>
      <link>https://dev.to/vipin_sharma/avoid-multi-threading-bugs-using-immutable-java-records-3ha</link>
      <guid>https://dev.to/vipin_sharma/avoid-multi-threading-bugs-using-immutable-java-records-3ha</guid>
      <description>&lt;p&gt;In a multi-threaded Java application, any thread can change the state of an object. &lt;a href="https://docs.oracle.com/javase/specs/jls/se16/html/jls-17.html#jls-17.4" rel="noopener noreferrer"&gt;Java memory model&lt;/a&gt; in Java language specification specifies when exactly updates made by one thread are going to be visible to other threads. This is one of the biggest problems professional java developers deal with every day. Java records are immutable, an object is considered immutable if its state cannot change after it is constructed. The immutable nature of the record eliminates problems of its usages in a multithreaded environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="https://jfeatures.com/blog/records" rel="noopener noreferrer"&gt;Previous blog post&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; on record explains how record provides a way to create data carrier-classes without writing a lot of boilerplate code. As part of this post, we will focus on the immutable feature of the record. Immutability is one of the best features provided by records, we can use a record object without worrying about other threads changing its state.&lt;/p&gt;



&lt;h3&gt;
  
  
  Java language features making record immutable
&lt;/h3&gt;

&lt;p&gt;In this section, we will go through a table explaining how records are made immutable in the Java language. In the below table the 2nd column explains different ways to update the state of a record object, the 3rd column explains Java language features that prevent updating the state of the Record object.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Index&lt;/th&gt;
&lt;th&gt;Way to update record&lt;/th&gt;
&lt;th&gt;Java language features preventing it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Create a record sub-class and change the state of the sub-class.&lt;/td&gt;
&lt;td&gt;Record classes are implicitly final and can not be abstract, this way we can not create a sub-class of the record class.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Extend some other class(superclass) and change the state of the superclass.&lt;/td&gt;
&lt;td&gt;All record classes extend java.lang.Record by default so can not extend any other class.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Add instance fields that can be modified.&lt;/td&gt;
&lt;td&gt;Record classes cannot declare instance fields.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Update record components.&lt;/td&gt;
&lt;td&gt;We can not assign a new value to record components as these are implicitly final. These are assigned values while initializing the record in a canonical constructor.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Update record components in the constructor.&lt;/td&gt;
&lt;td&gt;Only canonical constructor can update record components, which is called while initializing record. For other types of constructors, assigning any of the record components in the constructor body results in a compile-time error.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Update record components using reflection.&lt;/td&gt;
&lt;td&gt;Record components have specific handling in Reflection &lt;strong&gt;&lt;em&gt;&lt;a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Field.html#set(java.lang.Object,java.lang.Object)" rel="noopener noreferrer"&gt;Field API&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;. This treatment is like hidden classes. You can read more about Hidden classes &lt;strong&gt;&lt;em&gt;&lt;a href="https://jfeatures.com/blog/HiddenClass" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Shallowly immutable
&lt;/h3&gt;

&lt;p&gt;Record components are final, which means we can not change the record components once assigned. Although we can change fields of the record component, there is no restriction on that, it makes the record shallowly immutable. Let's see this with an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EmployeeTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;integerList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class="n"&gt;integerList&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;IntegerListRecord&lt;/span&gt; &lt;span class="n"&gt;integerListRecord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;IntegerListRecord&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;integerList&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;integerListRecord&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getListSize&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;

        &lt;span class="n"&gt;integerList&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;integerListRecord&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getListSize&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;IntegerListRecord&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;integerList&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;getListSize&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;integerList&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we created a list of integers(integerList), added one element into it, and initialized the record class with this. Calling method getListSize of record class results into 1. Now we add one more element in integerList and calling getListSize results into 2. Here we did not change the record component (integerList) but updated the fields of the record component, which does not have any restriction. This is the reason we call the record shallowly immutable.&lt;/p&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Records help you remove repetitive and error-prone code, and increases developer productivity. The immutability feature keeps it away from concurrency bugs. Using language features like this is going to make you a great developer everyone wants to hire.&lt;/p&gt;

&lt;p&gt;If you want to get amazing Java jobs, I wrote an ebook &lt;a href="https://jfeatures.com/" rel="noopener noreferrer"&gt;5 steps to Best Java Jobs&lt;/a&gt;. You can download this step-by-step guide for free!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jfeatures.com/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjfeatures.com%2Fimg%2Febook_upd.png"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://openjdk.java.net/jeps/395" rel="noopener noreferrer"&gt;JEP 395&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cr.openjdk.java.net/%7Ebriangoetz/amber/datum.html" rel="noopener noreferrer"&gt;https://cr.openjdk.java.net/~briangoetz/amber/datum.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.oracle.com/javase/specs/jls/se16/html/jls-17.html#jls-17.4" rel="noopener noreferrer"&gt;Java language specification: Java memory model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Reflection &lt;a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/reflect/Field.html#set(java.lang.Object,java.lang.Object)" rel="noopener noreferrer"&gt;Field API Javadoc&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>java16</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Java Records: concise and readable data carrier classes</title>
      <dc:creator>Vipin Sharma</dc:creator>
      <pubDate>Fri, 02 Apr 2021 09:56:07 +0000</pubDate>
      <link>https://dev.to/vipin_sharma/java-records-concise-and-readable-data-carrier-classes-3jlc</link>
      <guid>https://dev.to/vipin_sharma/java-records-concise-and-readable-data-carrier-classes-3jlc</guid>
      <description>&lt;h2&gt;
  
  
  Records
&lt;/h2&gt;

&lt;p&gt;Professional Java developers need immutable data carrier-classes for communication with databases, web Services. We need to write a lot of boilerplate code to create a simple data carrier-class, we typically implement constructor, accessors, equals(), hashCode(), and toString().  &lt;strong&gt;&lt;em&gt;This process is repetitive and error-prone. Developers also complain “Java is too verbose”.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Record classes provide a way to model data in java. An example of data is one row from a database table. This feature simplifies coding, makes java code more concise and readable. It is going to increase productivity for professional java developers. Java14 introduced Records as a preview feature, Java15 brings in some updates as a second preview and Java16 makes it a final feature, no changes in Record after this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common implementation use cases
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Multiple return values:&lt;/strong&gt; Often we encounter cases when we want to return multiple values from a method, for this we will have to create a class having values that we need to return. The record provides an easy way rather than writing boilerplate code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Data transfer objects (DTO):&lt;/strong&gt; Developers working with databases often write DTO which is typically used for storage only, we can again reduce boilerplate code using java Record classes.&lt;/p&gt;



&lt;h3&gt;
  
  
  Java code before and after Record
&lt;/h3&gt;

&lt;p&gt;Following is one example showing Point class without using record.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Point&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;   
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;    
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Point&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;    
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;getX&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{...}&lt;/span&gt;   
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;getY&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{...}&lt;/span&gt;   
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{...}&lt;/span&gt;   
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{...}&lt;/span&gt;   
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;hashCode&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{...)&lt;/span&gt;  
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Record equivalent for Point class is following one line, WOW !&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Point&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;){}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example record class name is Point, and it has 2 components x,y that describes state. The record class can have a body as well, later in this post we have such examples.&lt;/p&gt;

&lt;p&gt;We can use javap command to see the compiled class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;javac com/jfeatures/jdk16/records/Point.java 
javap &lt;span class="nt"&gt;-p&lt;/span&gt; com/jfeatures/jdk16/records/Point.class

Compiled from &lt;span class="s2"&gt;"Point.java"&lt;/span&gt;
final class com.jfeatures.jdk16.records.Point extends java.lang.Record &lt;span class="o"&gt;{&lt;/span&gt;
  private final int x&lt;span class="p"&gt;;&lt;/span&gt;
  private final int y&lt;span class="p"&gt;;&lt;/span&gt;
  com.jfeatures.jdk16.records.Point&lt;span class="o"&gt;(&lt;/span&gt;int, int&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public final java.lang.String toString&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public final int hashCode&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public final boolean equals&lt;span class="o"&gt;(&lt;/span&gt;java.lang.Object&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public int x&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public int y&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above output of the javap command we can see the record classes have:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A private final field for each component in record declaration(state description). (In the above example private final int x, private final int y)&lt;/li&gt;
&lt;li&gt;A public read accessor method for each component of the Record, with the same name and type as the parameter. (public int x(), public int y())&lt;/li&gt;
&lt;li&gt;A public constructor, having the same arguments as the components of the record, is also called a canonical constructor. This constructor initializes each field from the corresponding argument. (com.jfeatures.jdk16.records.Point(int, int))&lt;/li&gt;
&lt;li&gt;Implementations of equals and hashCode that say two record classes are equal if they are of the same type and contain the same state.&lt;/li&gt;
&lt;li&gt;An implementation of toString that includes the string representation of all the record components, with their names.&lt;/li&gt;
&lt;/ol&gt;



&lt;h3&gt;
  
  
  Record classes in detail
&lt;/h3&gt;

&lt;p&gt;Record classes behave like normal classes except restrictions, following are few properties of the Record classes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Can be declared as top-level or nested, can be generic.&lt;/li&gt;
&lt;li&gt;Can implement interfaces.&lt;/li&gt;
&lt;li&gt;Are instantiated via the new keyword.&lt;/li&gt;
&lt;li&gt;Record class body may declare static methods, static fields, static initializers, constructors, instance methods, and nested types.&lt;/li&gt;
&lt;li&gt;The record class and the individual components in a state description, can be annotated.&lt;/li&gt;
&lt;li&gt;We can define a nested record class. Nested record is implicitly static, because an immediately enclosing instance can add a state to the record.&lt;/li&gt;
&lt;li&gt;Instances of record classes can be serialized and deserialized. Serialization is done using Record components and deserialization is done using the canonical constructor. Serialization and deserialization can not be customized via regular means (writeObject, readObject, readObjectNoData, writeExternal, or readExternal methods).&lt;/li&gt;
&lt;/ol&gt;



&lt;h4&gt;
  
  
  Restrictions on record
&lt;/h4&gt;

&lt;p&gt;Following code shows compilation error in extends, because Record classes are implicitly final.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Base&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Base&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, we have a few more restrictions to follow for record classes.&lt;/p&gt;

&lt;p&gt;Restrictions on Record classes can be divided into 3 categories:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Restrictions that ensure the record class components alone defines the representation&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;record classes cannot extend any other class&lt;/li&gt;
&lt;li&gt;record classes cannot declare instance fields, only record components carry the state of the record object.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Restrictions that emphasize the API of a record is defined solely by its record components, and cannot be enhanced&lt;br&gt;
later by another class or record.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;record classes are implicitly final.&lt;/li&gt;
&lt;li&gt;record classes cannot be abstract.&lt;/li&gt;
&lt;li&gt;record classes cannot declare native methods.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restriction to make sure record is immutable by default.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The components of a record are implicitly final.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;h4&gt;
  
  
  Constructors
&lt;/h4&gt;

&lt;p&gt;Record classes have 3 types of constructors:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Canonical constructor&lt;/li&gt;
&lt;li&gt;Compact canonical constructor&lt;/li&gt;
&lt;li&gt;Custom constructor&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Canonical constructor&lt;/strong&gt;:&lt;br&gt;
    It contains all components of the record. This is declared implicitly, can be declared explicitly as well. Starting From Java15, if the canonical constructor is implicitly declared then its access modifier is the same as the record class. If the canonical constructor is explicitly declared then its access modifier must provide at least as much access as the record class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
       &lt;span class="nc"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
           &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
       &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Compact canonical constructor&lt;/strong&gt;:  It doesn't have any parameter, it is always called when defined. The compact form helps developers focus on validating and normalizing parameters. Here parameters are declared implicitly, and the private fields corresponding to record components are automatically assigned (this.x = x) at the end of the constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Employee&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;//validation&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;()==&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RuntimeException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Nota a valid name"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a Record class, only one out of canonical constructor or compact canonical constructor can be defined. Defining both results into compilation failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom constructor&lt;/strong&gt;: We can create custom constructors as well having only a few parameters from the Record header. Since this is not a canonical constructor, its first statement must invoke another constructor of the record class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
       &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
       &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Starting from Java 15 assigning any of the instance fields (record components) in the constructor body became a compile-time error. Only the canonical constructor is allowed to do this.&lt;/p&gt;



&lt;h4&gt;
  
  
  Update on &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt; annotation
&lt;/h4&gt;

&lt;p&gt;Java 15 extends the meaning of the &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt; annotation to include an explicitly declared accessor method for a record. Now following is valid java code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.jfeatures.jdk16.records&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h4&gt;
  
  
  Local record, enum, and interfaces are now allowed in Java
&lt;/h4&gt;

&lt;p&gt;Java15 introduced the ability to declare local record classes, local enum classes, and local interfaces. Nested record classes and local record classes are implicitly static. It avoids adding an immediate enclosing instance to the state of the record class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LocalComponents&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Start Test"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;LocalComponents&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;instanceMethod&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;instanceMethod&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;LocalRecord&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;LocalRecord&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Inside Local Record compact canonical constructors"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="kd"&gt;enum&lt;/span&gt; &lt;span class="nc"&gt;LocalEnum&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="no"&gt;VALUE1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
            &lt;span class="no"&gt;VALUE2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;LocalInterface&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Cloneable&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For versions before Java15, above code will not compile. Following is a compilation error for local enum in above example.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;com/jfeatures/jdk16/records/LocalComponents.java:16: error: enum types must not be local
enum LocalEnum {
^
1 error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Inner class can declare static members
&lt;/h4&gt;

&lt;p&gt;Before Java 16, an inner class can not declare a static member. Java 16 allows the inner class to declare a member of the type record class. This will allow an inner class to declare a member that is a record class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.jfeatures.jdk16.records&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RecordInInnerClass&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Starting test"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Inner&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;TestRecord&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code shows below compilation error with Java 15, it works fine with Java16 or later.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javac --enable-preview -source 15 com/jfeatures/jdk16/records/RecordInInnerClass.java
com/jfeatures/jdk16/records/RecordInInnerClass.java:9: error: static declarations not allowed in inner classes
record TestRecord(int id, String name){
^
Note: com/jfeatures/jdk16/records/RecordInInnerClass.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
1 error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why record, why not just tuples?
&lt;/h3&gt;

&lt;p&gt;A central aspect of Java's philosophy is that "names" matter.  A &lt;code&gt;Person&lt;/code&gt; with properties &lt;code&gt;firstName&lt;/code&gt; and &lt;code&gt;lastName&lt;/code&gt; is clearer and safer than a tuple of &lt;code&gt;String&lt;/code&gt; and &lt;code&gt;String&lt;/code&gt;.  &lt;/p&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Records help you remove repetitive and error prone code, reduce bugs in your code, reduces verbosity in code, and increases developer productivity. Using language features like this is going to make you a great developer everyone wants to hire.&lt;/p&gt;

&lt;p&gt;If you want to get amazing Java jobs, I wrote an ebook &lt;a href="https://jfeatures.com/" rel="noopener noreferrer"&gt;5 steps to Best Java Jobs&lt;/a&gt;. You can download this step-by-step guide for free!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jfeatures.com/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjfeatures.com%2Fimg%2Febook_upd.png"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;a href="https://openjdk.java.net/jeps/395" rel="noopener noreferrer"&gt;https://openjdk.java.net/jeps/395&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://cr.openjdk.java.net/%7Ebriangoetz/amber/datum.html" rel="noopener noreferrer"&gt;https://cr.openjdk.java.net/~briangoetz/amber/datum.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>productivity</category>
      <category>development</category>
    </item>
    <item>
      <title>Records: Data Carrier classes in Java 14</title>
      <dc:creator>Vipin Sharma</dc:creator>
      <pubDate>Mon, 03 Aug 2020 18:23:03 +0000</pubDate>
      <link>https://dev.to/vipin_sharma/records-data-carrier-classes-in-java-14-1kg7</link>
      <guid>https://dev.to/vipin_sharma/records-data-carrier-classes-in-java-14-1kg7</guid>
      <description>&lt;h2&gt;
  
  
  Records
&lt;/h2&gt;

&lt;p&gt;This feature is going to increase productivity for professional java developers. It simplifies coding, makes java code more concise and readable. Records provide a way to model data in java, example for data could be one row from the database table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common implementation use cases
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Multiple return values:&lt;/strong&gt; Often we encounter cases when we want to return multiple values from a method, for this we will have to create a class having values that we need to return. Record provides an easy way rather than writing boilerplate code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Data transfer objects (DTO):&lt;/strong&gt; Developers working with databases often write DTO which typically used for storage only, we can again reduce boilerplate code using java records.&lt;/p&gt;



&lt;h3&gt;
  
  
  Java code before and after Record
&lt;/h3&gt;

&lt;p&gt;To write even a simple data carrier class we have to write a lot of boilerplate code. Like constructors, accessors, equals(), hashCode(), toString(), etc. &lt;br&gt;
Following is one example showing Point class without using record.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Point
{
 public final int x;   
 public final int y;    
 public Point(int x, int y) { this.x = x; this.y = y; }    
 public int getX() {...}   
 public int getY() {...}   
 public String toString() {...}   
 public boolean equals(Object o) {...}   
 public int hashCode() {...)  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Record equivalent for Point class is following one line, WOW !&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Point&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;){}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example you can see, the record has a &lt;strong&gt;name&lt;/strong&gt; and a &lt;strong&gt;state description&lt;/strong&gt;. The state description declares the &lt;strong&gt;components&lt;/strong&gt; of the record. and y are here components of the record. The record can have a body as well, we will see this later in examples.&lt;/p&gt;

&lt;p&gt;This feature is in preview mode. To use the preview feature we need to pass --enable-preview parameter. Sample command for RecordsJDK14.java is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;javac &lt;span class="nt"&gt;--enable-preview&lt;/span&gt; &lt;span class="nt"&gt;-source&lt;/span&gt; 14 com/vip/jdk14/JavaRecords.java
java &lt;span class="nt"&gt;--enable-preview&lt;/span&gt; com.vip.jdk14.JavaRecords
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use javap command to see compiled class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;javac  &lt;span class="nt"&gt;--enable-preview&lt;/span&gt; &lt;span class="nt"&gt;-source&lt;/span&gt; 14 Point.java
javap &lt;span class="nt"&gt;-p&lt;/span&gt; Point.class

Compiled from &lt;span class="s2"&gt;"Point.java"&lt;/span&gt;
public final class com.vip.jdk14.Point extends java.lang.Record &lt;span class="o"&gt;{&lt;/span&gt;
  private final int x&lt;span class="p"&gt;;&lt;/span&gt;
  private final int y&lt;span class="p"&gt;;&lt;/span&gt;
  public com.vip.jdk14.Point&lt;span class="o"&gt;(&lt;/span&gt;int, int&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public java.lang.String toString&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public final int hashCode&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public final boolean equals&lt;span class="o"&gt;(&lt;/span&gt;java.lang.Object&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public int x&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  public int y&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above output of the javap command we can see following are properties of Records, Records have:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A private final field for each component in record declaration(state description). (In above example private final int x, private final int y)&lt;/li&gt;
&lt;li&gt;A public read accessor method for each component of Record, with the same name and type as the parameter. (public int x(), public int y())&lt;/li&gt;
&lt;li&gt;A public constructor, having the same arguments as the components of the record. This constructor initializes each field from the corresponding argument. (public com.vip.jdk14.Point(int, int))&lt;/li&gt;
&lt;li&gt;Implementations of equals and hashCode that say two records are equal if they are of the same type and contain the same state.&lt;/li&gt;
&lt;li&gt;An implementation of toString that includes the string representation of all the record components, with their names.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Records behave like normal classes except restrictions, following are few properties of the Records:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; They can be declared top level or nested, they can be generic.&lt;/li&gt;
&lt;li&gt; They can implement interfaces.&lt;/li&gt;
&lt;li&gt; They are instantiated via the new keyword.&lt;/li&gt;
&lt;li&gt; The record's body may declare static methods, static fields, static initializers, constructors, instance methods, and nested types.&lt;/li&gt;
&lt;li&gt; The record and the individual components in a state description can be annotated.&lt;/li&gt;
&lt;li&gt; We can define a nested record, which is implicitly static. It avoids an immediately enclosing instance that would silently add state to the record.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Records have 3 types of constructors we can define explicitly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Canonical constructor&lt;/strong&gt;: It contains all components of record.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Compact constructor&lt;/strong&gt;:  It doesn't have any parameter, it is always called when defined.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Custom constructor&lt;/strong&gt;: All others except above 2.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Following is an example of all 3 types of constructors we talked about.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;NameValue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//canonical constructor (It contains all components of record)&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;NameValue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;  
    &lt;span class="c1"&gt;//compact constructor, no parameter, always called when defined.&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;NameValue&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RuntimeException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//throwing Exception whenever value is 1, this is to test if it is called always.&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Custom constructor&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;NameValue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Necessary to avoid compilation error&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RuntimeException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Throwing Exception to test when is this called.&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  Restrictions on record
&lt;/h3&gt;

&lt;p&gt;Following code throws compilation error in extends, because Records are implicitly final.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Base&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; 
&lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Base&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, we have a few more restrictions to follow for Records.&lt;/p&gt;

&lt;p&gt;Restrictions on records can be divided into 3 categories:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Restrictions that ensure the state description alone defines the representation

&lt;ol&gt;
&lt;li&gt;Records cannot extend any other class&lt;/li&gt;
&lt;li&gt;Records cannot declare instance fields other than the private final fields which correspond to components of the state description. Any other fields which are declared must be static.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;Restrictions that emphasize the API of a record is defined solely by its state description, and cannot be enhanced later by another class or record.

&lt;ol&gt;
&lt;li&gt;Records are implicitly final.&lt;/li&gt;
&lt;li&gt;Records cannot be abstract.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;This restriction embodies an immutable by default policy.

&lt;ol&gt;
&lt;li&gt;The components of a record are implicitly final.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;



&lt;h3&gt;
  
  
  Why Record why not just tuples?
&lt;/h3&gt;

&lt;p&gt;A central aspect of Java's philosophy is that "names" matter.  A &lt;code&gt;Person&lt;/code&gt; with properties &lt;code&gt;firstName&lt;/code&gt; and &lt;code&gt;lastName&lt;/code&gt; is clearer and safer than a tuple of &lt;code&gt;String&lt;/code&gt; and &lt;code&gt;String&lt;/code&gt;.  &lt;/p&gt;



&lt;h3&gt;
  
  
  At the end
&lt;/h3&gt;

&lt;p&gt;To learn the best java language features and get the best Java Jobs, download my ebook &lt;a href="https://jfeatures.com/"&gt;5 steps to Best Java Jobs&lt;/a&gt; for Free.&lt;/p&gt;

&lt;p&gt;Follow me on twitter &lt;a href="https://twitter.com/vipinbit"&gt;@vipinbit&lt;/a&gt; to get daily tips like this on Java Language Features.&lt;/p&gt;



&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;a href="https://openjdk.java.net/jeps/359"&gt;https://openjdk.java.net/jeps/359&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://cr.openjdk.java.net/%7Ebriangoetz/amber/datum.html"&gt;https://cr.openjdk.java.net/~briangoetz/amber/datum.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://github.com/Vipin-Sharma/JDK14Examples"&gt;https://github.com/Vipin-Sharma/JDK14Examples&lt;/a&gt;, this repository has all code we discussed in this post.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>productivity</category>
      <category>java14</category>
    </item>
    <item>
      <title>Text Blocks: No more errors in Java multi-line Strings</title>
      <dc:creator>Vipin Sharma</dc:creator>
      <pubDate>Sat, 01 Aug 2020 01:00:00 +0000</pubDate>
      <link>https://dev.to/vipin_sharma/no-more-errors-in-java-multi-line-strings-using-text-blocks-34i9</link>
      <guid>https://dev.to/vipin_sharma/no-more-errors-in-java-multi-line-strings-using-text-blocks-34i9</guid>
      <description>&lt;h3&gt;
  
  
  Do you find Java multiline Strings not readable?
&lt;/h3&gt;

&lt;p&gt;Multi-line strings in java are often not readable which makes it error-prone. JDK 15 Standard feature Text blocks provide us a better way to write strings that span several lines of source code.&lt;/p&gt;

&lt;p&gt;Let's check the java code example to understand how text blocks make our code more readable and bug-free. &lt;/p&gt;

&lt;p&gt;Can you spot a bug in the multiline String below?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;oldMultiLineStringSQL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"select emp_id, emp_name, emp_num_of_kids, emp_active"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                             &lt;span class="s"&gt;"from employee_table"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                             &lt;span class="s"&gt;"where employee_num_of_kids =1"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oldMultiLineStringSQL&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the console output for oldMultiLineStringSQL. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;select emp_id, emp_name, emp_num_of_kids, &lt;strong&gt;&lt;em&gt;emp_&lt;span&gt;activefrom&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;employee_&lt;span&gt;tablewhere&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt; employee_num_of_kids =1&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this output notice the words in bold, here we don't have spaces between words of consecutive lines. It causes SQLSyntaxErrorException.&lt;/p&gt;

&lt;p&gt;Next section we will see how this problem can be solved by Text blocks. &lt;/p&gt;



&lt;h3&gt;
  
  
  Text Blocks Java code
&lt;/h3&gt;

&lt;p&gt;Now the same code we are writing using Java Text Blocks.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String sqlWithTextBlocks = """
                select emp_id, emp_name, emp_num_of_kids, emp_active      
                from employee_table      
                where employee_num_of_kids =1 
                """; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Following is console output for text blocks, it is the same as we have written in code. No issues due to space among consecutive lines.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;select emp_id, emp_name, emp_num_of_kids, emp_active&lt;br&gt;
from employee_table&lt;br&gt;
where employee_num_of_kids =1&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3&gt;
  
  
  The deep dive into Text block syntax
&lt;/h3&gt;

&lt;p&gt;A text block consists of zero or more content characters, enclosed by opening and closing delimiters.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;The opening delimiter&lt;/em&gt;&lt;/strong&gt; is a sequence of three double-quote characters (""") followed by zero or more white spaces followed by a line terminator.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;The closing delimiter&lt;/em&gt;&lt;/strong&gt; is a sequence of three double-quote characters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;The content&lt;/em&gt;&lt;/strong&gt; begins at the first character after the line terminator of the opening delimiter and ends before the closing delimiter.&lt;/li&gt;
&lt;/ol&gt;



&lt;h3&gt;
  
  
  Text blocks compile-time processing
&lt;/h3&gt;

&lt;p&gt;The content of a text block is processed by the Java compiler in three steps in the same sequence as given below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Line terminators&lt;/em&gt;&lt;/strong&gt;:               Line terminators in the content are translated to LF (\u000A).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Common white spaces removal&lt;/em&gt;&lt;/strong&gt;:           Incidental white space surrounding the content, introduced to match the indentation of Java source code is removed in this step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Escape sequence processing&lt;/em&gt;&lt;/strong&gt;:     Escape sequences in the content are interpreted in this step. Performing interpretation as the final step means developers can write escape sequences such as \n without them being modified or deleted by earlier steps.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The following sections have all 3 steps of compile-time processing in more detail.&lt;/p&gt;

&lt;h4&gt;
  
  
  Line terminators
&lt;/h4&gt;

&lt;p&gt;Different operating systems have their &lt;a href="https://en.wikipedia.org/wiki/Newline"&gt;Line terminators&lt;/a&gt;.&lt;br&gt;
All line terminators (CR/LF/CRLF) in the content are translated into LF (\u000A). &lt;br&gt;
It makes the same java code work across all platforms.&lt;/p&gt;
&lt;h4&gt;
  
  
  White space removal
&lt;/h4&gt;

&lt;p&gt;Following two rules help us understand whitespace removal.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; There has to be one line terminator immediately after the initial opening delimiter.&lt;/li&gt;
&lt;li&gt; Now we have content and closing delimiter. if we move any line of content or closing delimiter to left it reduces common whitespace prefix. In other words, left most character in content or end delimiter decides the starting character of all lines in the text block.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's check some examples to understand how it works in practice.&lt;/p&gt;

&lt;p&gt;In all the examples&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;dots (.) are used to show spaces in code.&lt;/li&gt;
&lt;li&gt;Vertical bars (|) are used to visualize the left margin.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This is the first example&lt;/em&gt;&lt;/strong&gt; having no whitespaces in the output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void printTextBlock() {
....String textBlock = """
............First line of test block
............Second line of test block
............""";
....System.out.println(textBlock);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the Intellij idea screenshot for the above code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FkzHByi7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printTextBlock.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FkzHByi7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printTextBlock.png" alt="SS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following is the output, showing all incidental white spaces removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|First line of test block
|Second line of test block
|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;This is the second example&lt;/em&gt;&lt;/strong&gt; showing initial character position in the text block is decided by the start of the second line in text block content, out of all lines of content and end delimiter here, the second line has leftmost character.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void printInitialCharacterPositionDecidedByLeftMostCharacterOfLines() {
....String textBlock = """
............First line of test block
........Second line of test block
............""";
....System.out.println(textBlock);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the Intellij idea screenshot for the above code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OyWniunt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printInitialCharacterPositionDecidedByLeftMostCharacterOfLines.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OyWniunt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printInitialCharacterPositionDecidedByLeftMostCharacterOfLines.png" alt="SS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following is the output of the second example. We can see the initial 4 spaces that are common are removed in output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|    First line of test block
|Second line of test block
|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;This is the third example&lt;/em&gt;&lt;/strong&gt; showing the effect of moving the end delimiter to left.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void printInitialCharacterPositionDecidedByEndDelimiter() {
....String textBlock = """
............First line of test block........
............Second line of test block........
........""";
....System.out.println(textBlock);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the Intellij idea screenshot for the above code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fY4ys687--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printInitialCharacterPositionDecidedByEndDelimiter.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fY4ys687--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printInitialCharacterPositionDecidedByEndDelimiter.png" alt="SS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the following output of the third example. We can see spaces at the end of the line are removed. Moving the end delimiter 4 spaces to left adds 4 spaces in all the lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|    First line of test block
|    Second line of test block
|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;This is the fourth example&lt;/em&gt;&lt;/strong&gt; showing the effect of moving the end delimiter to right. Here we see moving the end delimiter to the right of content has no effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void printTextBlockMovingEndDelimiterToRightOfContentHasNoEffect()
{
....String textBlock = """
............First line of test block         
............Second line of test block      
................""";
....System.out.println(textBlock);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the Intellij idea screenshot for the above code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K1pv6jVn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printTextBlockMovingEndDelimiterToRightOfContentHasNoEffect.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K1pv6jVn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/posts/printTextBlockMovingEndDelimiterToRightOfContentHasNoEffect.png" alt="SS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following is the output of the fourth example, it shows no effect of moving the end delimiter to left, all common white spaces are removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|First line of test block
|Second line of test block
|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In all these examples you can see the green vertical bar in the IntelliJ idea shows the starting character of lines in the text block.&lt;/p&gt;



&lt;h4&gt;
  
  
  Escape processing
&lt;/h4&gt;

&lt;p&gt;This is the third and last step of compile-time processing. We have seen first line terminators are interpreted, then the next step is white space removal and at the end escape processing. And because this is the last step in compile-time processing when we use \n (or any other escape sequence) in text block content, it will not be modified by the initial 2 steps and will be interpreted at the end.&lt;/p&gt;

&lt;p&gt;Let's learn different language features in escape processing using the below code example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private static void printEscapeProcessing() {
....String textBlock = """
............"Hello\n
............Text Block " ' \\ \t "
............experiment another opening/closing delimiter type of 3 consecutive quotes \"""
............without newline concatenation of Strings \
............spaces \s\sat end in this way trailing spaces are not removed\s\s
............\"""";
....System.out.println("printEscapeProcessing");
....System.out.println(textBlock);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the output of the above escape processing example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|printEscapeProcessing
|"Hello
|
|Text Block " ' \   "
|experiment another opening/closing delimiter type of 3 consecutive quotes """
|without newline concatenation of Strings spaces ..at end in this way trailing spaces are not removed..  
|"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above output few things to observe are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;\n&lt;/code&gt; is allowed in the text block, and it generates an additional new line in the output.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"&lt;/code&gt; and &lt;code&gt;'&lt;/code&gt; can be used anywhere in text blocks like Strings.&lt;/li&gt;
&lt;li&gt;to use &lt;code&gt;\&lt;/code&gt; we need to use &lt;code&gt;\\&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Sequences of three double quotes &lt;code&gt;"""&lt;/code&gt; characters require the escaping of at least one &lt;code&gt;"&lt;/code&gt; to avoid mimicking the closing delimiter.&lt;/li&gt;
&lt;li&gt;To allow finer control of the processing of the newlines and white space, two new escape sequences are introduced in java 15, these were not present in earlier preview versions.

&lt;ol&gt;
&lt;li&gt;   &lt;code&gt;\&lt;/code&gt; at the end acts like a concatenation of 2 Strings, in other words, it avoids line terminator between consecutive lines.&lt;/li&gt;
&lt;li&gt;   &lt;code&gt;\s&lt;/code&gt; adds space, in example output spaces are shown with dots (&lt;code&gt;.&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;



&lt;h3&gt;
  
  
  Common mistakes in text blocks
&lt;/h3&gt;

&lt;p&gt;Here are some examples of ill-formed text blocks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String a = """""";   // no line terminator after opening delimiter
String b = """ """;  // no line terminator after opening delimiter
String c = """
           ";        // no closing delimiter
String d = """
           abc \ def
           """;      // unescaped backslashs

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  At the end
&lt;/h3&gt;

&lt;p&gt;Knowing language features like this helps you get the best java jobs, that's why to help you I wrote the ebook &lt;a href="https://jfeatures.com/"&gt;5 steps to Best Java Jobs&lt;/a&gt;.&lt;br&gt;
Download this step by step guide for free!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jfeatures.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4odhEdOL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jfeatures.com/img/ebook.png" width="200" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://openjdk.java.net/jeps/378"&gt;https://openjdk.java.net/jeps/378&lt;/a&gt;, This is the Java enhancement proposal for text blocks in JDK15.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/Vipin-Sharma/JDK15Examples"&gt;https://github.com/Vipin-Sharma/JDK15Examples&lt;/a&gt;, this is the link to code examples used in this post.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>productivity</category>
      <category>jdk15</category>
    </item>
    <item>
      <title>Can NullPointerException be helpful?</title>
      <dc:creator>Vipin Sharma</dc:creator>
      <pubDate>Wed, 08 Jul 2020 04:07:31 +0000</pubDate>
      <link>https://dev.to/vipin_sharma/can-nullpointerexception-be-helpful-2j57</link>
      <guid>https://dev.to/vipin_sharma/can-nullpointerexception-be-helpful-2j57</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Have you ever received NullPointerException ?&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Every Java developer has encountered NullPointerExceptions, this is most common programming error new Java Developers face.&lt;/p&gt;

&lt;p&gt;Following is one simple programming mistake, I am trying to call method size on null list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NullPointerExceptionDemo&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is output of running NullPointerExceptionDemo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Exception in thread "main" java.lang.NullPointerException
at com.vip.jdk14.NullPointerExceptionDemo.main(NullPointerExceptionDemo.java:8)

Process finished with exit code 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In above example it is clear list is null but several other situation it is not easy to understand root cause. See following example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;objectA&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getObjectB&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getObjectC&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getObjectD&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you may get NullPointerException, when &lt;strong&gt;&lt;em&gt;objectA&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;objectA.getObjectB()&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;objectA.getObjectB().getObjectC()&lt;/em&gt;&lt;/strong&gt; any of them is null. And you get same NullPointerException message in all these cases.&lt;/p&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Java 14 can show you root cause of NullPointerException&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now Java 14 has added language feature to show root cause of NullPointerException.&lt;br&gt;
This language feature has been part of &lt;a href="https://twitter.com/SweetSapMachine"&gt;SAP&lt;/a&gt; commercial JVM since 2006.&lt;/p&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Helpful NullPointerException&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In Java 14 you can start passing -XX:+ShowCodeDetailsInExceptionMessages in VM arguments and it helps you to see root cause of NullPointerException.&lt;br&gt;
In Java 14 option is disabled by default and in later releases this will be enabled by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HelpfulNullPointerExceptionDemo&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running this program prints following Exception message, and root cause is clearly written &lt;strong&gt;&lt;em&gt;list is null&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "list" is null
at com.vip.jdk14.HelpfulNullPointerExceptionDemo.main(HelpfulNullPointerExceptionDemo.java:8)

Process finished with exit code 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;At the end&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To learn the best java language features and get the best Java Jobs, download my ebook &lt;a href="https://jfeatures.com/"&gt;5 steps to Best Java Jobs&lt;/a&gt; for Free.&lt;/p&gt;

&lt;p&gt;Follow me on twitter &lt;a href="https://twitter.com/vipinbit"&gt;@vipinbit&lt;/a&gt; to get daily tips like this on Java Language Features.&lt;/p&gt;

</description>
      <category>java</category>
      <category>exception</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
