<?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: Joshua Austin</title>
    <description>The latest articles on DEV Community by Joshua Austin (@joshaustintech).</description>
    <link>https://dev.to/joshaustintech</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%2F182232%2F00a3c5d9-fdb3-466c-bcb3-7954b425637f.jpeg</url>
      <title>DEV Community: Joshua Austin</title>
      <link>https://dev.to/joshaustintech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joshaustintech"/>
    <language>en</language>
    <item>
      <title>What is the Twitter Endgame?</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Tue, 28 Feb 2023 04:53:43 +0000</pubDate>
      <link>https://dev.to/joshaustintech/what-is-the-twitter-endgame-4ap5</link>
      <guid>https://dev.to/joshaustintech/what-is-the-twitter-endgame-4ap5</guid>
      <description>&lt;h2&gt;
  
  
  Disclaimer: This is pure speculation
&lt;/h2&gt;

&lt;p&gt;I have no crystal ball, and there's always the possibility Elon's inflated ego could get the best of him while he thinks he's playing 4D chess. It's also possible that his strategy will pay off in some other way I am not seeing right now. BUT...based on what I'm observing this is what I think is going to happen to Twitter in the not-so-distant future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Elon isn't going to hire a new CEO until Twitter fundamentally changes
&lt;/h2&gt;

&lt;p&gt;That is because Twitter, as a company, will be shut down or completely reorganized into something different. Why? Read on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Jack Dorsey believes Twitter should not have been a company
&lt;/h2&gt;

&lt;p&gt;Instead, the original CEO of Twitter &lt;a href="https://qz.com/jack-dorsey-said-making-twitter-a-company-was-its-orig-1849603325" rel="noopener noreferrer"&gt;believes it should be an open source protocol, and told Musk the same.&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  The protocol is in active development
&lt;/h2&gt;

&lt;p&gt;Check out the &lt;a href="https://atproto.com/" rel="noopener noreferrer"&gt;AT Protocol.&lt;/a&gt; It attempts to resolve some shortcomings other social platforms have, such as giving content discovery and curation to third parties.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4u5uzjd8tyk968acu8u9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4u5uzjd8tyk968acu8u9.png" alt=" " width="800" height="681"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This could enable users to take the ever-present issue of online harassment and bullying into their own hands by implementing their own tools to fight back rather than wait for the Twitter CEO to realize that it's a problem. For example (one out of myriad, to be sure), Jack knew that Antisemitism was a problem on Twitter and confirmed to the Israeli tech influencer &lt;a href="https://twitter.com/HilzFuld" rel="noopener noreferrer"&gt;Hillel Fuld&lt;/a&gt; that &lt;a href="https://twitter.com/HilzFuld/status/824937539458957316?s=20" rel="noopener noreferrer"&gt;the Twitter team would do something about it&lt;/a&gt;. 5 years later, those words seem to have rung hollow. Perhaps Jack now hopes that this protocol will finally enable users to address this?&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm guessing will happen
&lt;/h2&gt;

&lt;p&gt;I can see Musk working to run Twitter aground and then reorganizing Twitter into an open source foundation that funds and oversees the AT Protocol, among other open web protocols. I could also see Twitter running the "reference implementation" of the AT protocol and offering premium paid support for others who want to deploy their own implementations (much like how Gradle and Kafka are open source but have premium paid services today).&lt;/p&gt;

&lt;p&gt;This could bring unprecedented freedom in the form of enabling individuals and organizations taking complete ownership of their social platform rather than having it shackled to a few walled gardens.&lt;/p&gt;

&lt;p&gt;The vacuum caused by the collapse of Twitter will result in several companies offering social media hosting and platforms based on the AT Protocol. The less technically adept will flock to these. The more technically adept will self-host their platform much like a handful of users self-host Mastodon instances today.&lt;/p&gt;

&lt;p&gt;What will be a major challenge to all this are &lt;a href="https://www.wired.com/story/mastodon-legal-issues-tipping-point/" rel="noopener noreferrer"&gt;the layers of legal ramifications&lt;/a&gt; such as those Mastodon approached during its moments of growth in late 2022.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The Twitter Endgame may involve the end of Twitter as we know it right now, but I am hopeful that the purpose in this is to replace it with something better. Even if Twitter doesn't fully run aground, I fully plan to utilize the AT Protocol as soon as it reaches some degree of usability since I am a big believer in completely owning my online platform someday instead of depending on social platforms for reach.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>How to Concatenate Strings in Java like a Pro</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Sat, 18 Feb 2023 18:43:16 +0000</pubDate>
      <link>https://dev.to/joshaustintech/how-to-concatenate-strings-in-java-like-a-pro-3c33</link>
      <guid>https://dev.to/joshaustintech/how-to-concatenate-strings-in-java-like-a-pro-3c33</guid>
      <description>&lt;p&gt;String concatenation in Java can be initially tricky, especially if you come from other programming languages. When Java was first implemented, the decision was made to render the &lt;code&gt;String&lt;/code&gt; class immutable. So what if you have to concatenate two or more strings? I remember being instructed to rely on the &lt;code&gt;StringBuilder&lt;/code&gt; class like so:&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;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;sb&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;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Gandalf"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&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="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"The"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&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="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Grey"&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;gandalf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prior to Java 8, this was more efficient. However, now the compiler handles that for you by making + operations into StringBuilder operations at compile time.&lt;/p&gt;

&lt;p&gt;However, this implementation is very naïve.&lt;/p&gt;

&lt;p&gt;If this 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="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Frodo"&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;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Baggins"&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;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firstName&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="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;translates to this equivalent at compile time...&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;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Frodo"&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;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Baggins"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;sb&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;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&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="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lastName&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;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...what happens during a loop?&lt;/p&gt;

&lt;p&gt;Unfortunately, this 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="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hobbits&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;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Frodo"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Samwise"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Merry"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Pippin"&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;greetAllHobbits&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="k"&gt;for&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;hobbit&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hobbits&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;greetAllHobbits&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;"Greetings, "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hobbit&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"!\n"&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;translates to roughly this equivalent at compile time&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;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hobbits&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;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Frodo"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Samwise"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Merry"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Pippin"&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;greetAllHobbits&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="k"&gt;for&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;hobbit&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hobbits&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;sb&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;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;greetAllHobbits&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Greetings, "&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hobbit&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"!\n"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;greetAllHobbits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&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;A separate &lt;code&gt;StringBuilder&lt;/code&gt; instance is created during each iteration, which can defeat the purpose of being efficient!&lt;/p&gt;

&lt;p&gt;In the above case, you'll need to create a &lt;code&gt;StringBuilder&lt;/code&gt; outside the loop so you aren't creating an unnecessary new object for each iteration.&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;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hobbits&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;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Frodo"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Samwise"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Merry"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Pippin"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;StringBuilder&lt;/span&gt; &lt;span class="n"&gt;sb&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;StringBuilder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;for&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;hobbit&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hobbits&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Greetings, "&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hobbit&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;append&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"!\n"&lt;/span&gt;&lt;span class="o"&gt;);&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;greetAllHobbits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;+&lt;/code&gt; when concatenating ad hoc&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;StringBuilder&lt;/code&gt; when concatenating with a loop&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>featurerequest</category>
      <category>discuss</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Java It Is! A Q1 Check-In</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Sat, 18 Feb 2023 05:11:22 +0000</pubDate>
      <link>https://dev.to/joshaustintech/java-it-is-a-q1-check-in-3022</link>
      <guid>https://dev.to/joshaustintech/java-it-is-a-q1-check-in-3022</guid>
      <description>&lt;p&gt;I was really pumped to &lt;a href="https://dev.to/joshaustintech/excited-for-2023-4939"&gt;cover a lot of developer topics this year&lt;/a&gt;. After a month and a half of trying to squeeze everything together, I've come to the realization I simply don't have the time to learn and build everything I want to. And that's OK.&lt;/p&gt;

&lt;p&gt;An older friend who retired comfortably from the spoils of the .COM Era shared some simple yet profound bits of advice this week when I asked him what was his recipe for success:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Focus on what you know best.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For me, that would definitely be Java.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How can I make my family's life better?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So far, for my situation, it's sticking with Java. In my current situation, the majority of the highest-paying jobs are in Java.&lt;/p&gt;

&lt;p&gt;Around the same time I encountered &lt;a href="https://world.hey.com/dhh/invest-in-things-that-don-t-change-6f7f19e1" rel="noopener noreferrer"&gt;DHH's article on investing in things that don't change&lt;/a&gt;. Java is definitely still very familiar even if you haven't touched it in 10 years.&lt;/p&gt;

&lt;p&gt;That doesn't mean I'll stop exploring other things, like Rust and blockchains and Swift (oh my!), but I need to deliberately spend less time on those other things so I can sharpen the strongest skill I have.&lt;/p&gt;

&lt;p&gt;I've started working on my first RIFE2 project, and I've started reading a book on the Java game engine FXGL. These should keep me preoccupied for a while. If I run out of Java-related things to do I expect to revisit &lt;a href="https://jbake.org/" rel="noopener noreferrer"&gt;JBake&lt;/a&gt; and maybe Java for Android.&lt;/p&gt;

</description>
      <category>hackathon</category>
      <category>ai</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Getting Started with RIFE2</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Sun, 29 Jan 2023 08:19:16 +0000</pubDate>
      <link>https://dev.to/joshaustintech/getting-started-with-rife2-1jih</link>
      <guid>https://dev.to/joshaustintech/getting-started-with-rife2-1jih</guid>
      <description>&lt;h2&gt;
  
  
  The Vaporous Nature of Web Development
&lt;/h2&gt;

&lt;p&gt;The web has changed significantly since I started my first developer role. So have web frameworks. So have programming languages!&lt;/p&gt;

&lt;p&gt;Despite an &lt;strong&gt;incorrect&lt;/strong&gt; reputation of being "old" and "slow", Java has enjoyed a second wind in recent years thanks to a combination of &lt;a href="https://en.wikipedia.org/wiki/Network_effect" rel="noopener noreferrer"&gt;the Network Effect&lt;/a&gt; and the regular but stable release cycles. It used to take &lt;em&gt;forever&lt;/em&gt; for new Java releases to arrive, but now we can enjoy regular releases every 6 months and Long-Term Support (LTS) releases every 2 years! Java has also gained higher runtime speed, and projects like &lt;a href="https://www.graalvm.org/" rel="noopener noreferrer"&gt;GraalVM&lt;/a&gt; and &lt;a href="https://www.azul.com/blog/superfast-application-startup-java-on-crac/" rel="noopener noreferrer"&gt;CRaC&lt;/a&gt; are looking to give Java even more speed.&lt;/p&gt;

&lt;p&gt;As the Java language evolves, so have the web frameworks. As of the writing of this article, Spring Framework 6 and Spring Boot 3 have recently launched, ushering in the next generation of &lt;a href="https://en.wikipedia.org/wiki/Convention_over_configuration" rel="noopener noreferrer"&gt;Convention Over Configuration&lt;/a&gt; development for the Java community.&lt;/p&gt;

&lt;p&gt;Spring Boot is my go-to for server-side development, especially for REST API microservices. However, what if you want to prototype something simple and have lower-level control? What if you want to run a simple website over a single Java file with no annotations and no dependency injection?&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter RIFE2.
&lt;/h2&gt;

&lt;p&gt;RIFE2 enables quick and simple prototyping, development, and testing without all the bells and whistles. It also ships with a simple two-way, logic-less templating engine.&lt;/p&gt;

&lt;p&gt;Best of all, it's &lt;em&gt;meant&lt;/em&gt; for modern Java syntax!&lt;/p&gt;

&lt;h2&gt;
  
  
  Hello World in RIFE2
&lt;/h2&gt;

&lt;p&gt;Given a simple Java + Gradle project layout, running Hello World in RIFE2 is surprisingly little code.&lt;/p&gt;

&lt;p&gt;If running a standlone JAR like I am, your &lt;code&gt;build.gradle&lt;/code&gt; needs to include not just RIFE2, but also Jetty for the underlying server engine and an SLF4J provider for logging. It should look something like this in the dependencies section (but likely with newer version numbers by the time you read this):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="n"&gt;dependencies&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s1"&gt;'com.uwyn.rife2:rife2:0.9.5'&lt;/span&gt;
    &lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="s1"&gt;'org.slf4j:slf4j-simple:2.0.6'&lt;/span&gt;
    &lt;span class="n"&gt;testImplementation&lt;/span&gt; &lt;span class="s1"&gt;'org.junit.jupiter:junit-jupiter:5.9.1'&lt;/span&gt;

    &lt;span class="n"&gt;runtimeOnly&lt;/span&gt; &lt;span class="s1"&gt;'org.eclipse.jetty:jetty-server:11.0.12'&lt;/span&gt;
    &lt;span class="n"&gt;runtimeOnly&lt;/span&gt; &lt;span class="s1"&gt;'org.eclipse.jetty:jetty-servlet:11.0.12'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now for the Java code (minus the package name):&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;import&lt;/span&gt; &lt;span class="nn"&gt;rife.engine.Server&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;rife.engine.Site&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;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Site&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;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/hello"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World"&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="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="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Server&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;start&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;App&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;That should be it!!! Now, if you call &lt;code&gt;gradle run&lt;/code&gt; in the terminal you should be able to see output for something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; Task :app:run
[main] INFO org.eclipse.jetty.server.Server - jetty-11.0.12; built: 2022-09-14T02:38:00.723Z; git: d5b8c29485f5f56a14be5f20c2ccce81b93c5555; jvm 17.0.5+9-LTS-191
[main] INFO org.eclipse.jetty.server.session.DefaultSessionIdManager - Session workerName=node0
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@6fb0d3ed{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@64c64813{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[main] INFO org.eclipse.jetty.server.Server - Started Server@598067a5{STARTING}[11.0.12,sto=0] @172ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the server is running on port 8080. Checking the URL &lt;code&gt;localhost:8080/hello&lt;/code&gt; in the browser should display "Hello World" in the browser.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I'm very excited to see what web projects, both big and small, can be accomplished with such a self-contained framework like RIFE2. And we've only scratched the surface! There's a built-in &lt;a href="https://github.com/gbevin/rife2/wiki/Bidirectional-Templates" rel="noopener noreferrer"&gt;template system&lt;/a&gt;, &lt;a href="https://github.com/gbevin/rife2/wiki/Continuations" rel="noopener noreferrer"&gt;Continuations&lt;/a&gt;, and much more. Definitely &lt;a href="https://dev.tourl"&gt;read the docs&lt;/a&gt; if you want to dig deeper into this framework. Also, be sure to thank the framework author, &lt;a href="https://twitter.com/gbevin" rel="noopener noreferrer"&gt;Geert Bevin&lt;/a&gt;, for the amount of effort he has put into this!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Excited for 2023!</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Sun, 01 Jan 2023 09:14:01 +0000</pubDate>
      <link>https://dev.to/joshaustintech/excited-for-2023-4939</link>
      <guid>https://dev.to/joshaustintech/excited-for-2023-4939</guid>
      <description>&lt;p&gt;2023 has a lot in store, and I can't wait to get started! In 2022 I worked full time in Java while exploring several other programming languages on my free time, resulting in the &lt;a href="https://twitter.com/joshaustintech/status/1609294295818768385?s=20"&gt;busiest GitHub activity I've ever had&lt;/a&gt;! I have finally determined which secondary language to focus into becoming a marketable skill this year: Swift.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Swift?
&lt;/h2&gt;

&lt;p&gt;A lot of mobile developers have specialized in cross-platform app development using React Native and Flutter. I'm impressed with Flutter and expect to revisit it once I have gained work experience as a Swift developer, but I believe that the industry emphasis on cross-platform development has created a greater shortage in native Apple iPhone, iPad, and macOS developers. I really enjoy (most of) the user experiences that Apple devices have to offer and intend to take advantage of this skill shortage.&lt;/p&gt;

&lt;p&gt;I know I'm very late to the party, and I expect that understanding Apple's frameworks like UIKit, SwiftUI, ARKit, etc. does not happen quickly, but it does mean that there are enough possibilities to explore to keep the journey from ever becoming a boring one!&lt;/p&gt;

&lt;p&gt;This doesn't mean I won't be active in the Java community anymore. On the contrary, I &lt;a href="https://www.linkedin.com/posts/joshaustintech_newjob-java-ugcPost-7013135642012372992-7oB8?utm_source=share&amp;amp;utm_medium=member_desktop"&gt;accepted a new job offer&lt;/a&gt; to work in Java full-time and expect some exciting developments in the Java ecosystem this year.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is in store for Java in 2023?
&lt;/h2&gt;

&lt;p&gt;Java seems to have gained a second wind in recent years, and the innovation in this ecosystem is speeding up. Java &lt;a href="https://openjdk.org/projects/jdk/20/"&gt;20&lt;/a&gt; and &lt;a href="https://openjdk.org/projects/jdk/21/"&gt;LTS release 21&lt;/a&gt; are expected to happen this year. &lt;a href="https://github.com/gbevin/rife2"&gt;RIFE2, an actively-developed pure-Java web framework&lt;/a&gt;, has recently caught my attention. Like &lt;a href="https://javalin.io/"&gt;Javalin&lt;/a&gt;, it appears to be built on top of the successful Jetty server. I also started exploring &lt;a href="https://github.com/AlmasB/FXGL"&gt;FXGL&lt;/a&gt; for building games with Java. Lastly, as concerns over COVID-19 variants wane I expect an increase in Java developers participating in community events. For example, Chicago finally had its first &lt;a href="https://twitter.com/joshaustintech/status/1574765558419148803"&gt;in-person JConf event&lt;/a&gt; and the &lt;a href="https://www.meetup.com/chicagojug"&gt;Chicago Java User Group (CJUG)&lt;/a&gt; is easing back into &lt;a href="https://twitter.com/joshaustintech/status/1579997524450217987"&gt;in-person events&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What new developer technologies are you the most excited about? Are you looking forward to going back to in-person events this year? &lt;/p&gt;

</description>
      <category>java</category>
      <category>swift</category>
    </item>
    <item>
      <title>Besides good coding and good teamwork, how do I "level up" as a developer?</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Tue, 18 Jun 2019 07:27:05 +0000</pubDate>
      <link>https://dev.to/joshaustintech/besides-good-coding-and-good-teamwork-how-do-i-level-up-as-a-developer-5ff</link>
      <guid>https://dev.to/joshaustintech/besides-good-coding-and-good-teamwork-how-do-i-level-up-as-a-developer-5ff</guid>
      <description>&lt;p&gt;I'm honing in on my coding abilities and interpersonal skills at work. Besides good coding and good teamwork, how do I "level up" as a developer? Senior devs, what helped you the most?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>productivity</category>
      <category>career</category>
      <category>seniordev</category>
    </item>
    <item>
      <title>Those sneaky NullPointerExceptions!</title>
      <dc:creator>Joshua Austin</dc:creator>
      <pubDate>Tue, 18 Jun 2019 07:14:45 +0000</pubDate>
      <link>https://dev.to/joshaustintech/those-sneaky-nullpointerexceptions-580c</link>
      <guid>https://dev.to/joshaustintech/those-sneaky-nullpointerexceptions-580c</guid>
      <description>&lt;p&gt;There is a form of driving called "defensive driving". Defensive drivers anticipate accidents and bad drivers. This lowers the chances of getting into accidents. It has saved me from several bad accidents.&lt;/p&gt;

&lt;p&gt;Similarly, we can avoid the scary &lt;code&gt;NullPointerException&lt;/code&gt; in Java if we know how to anticipate it.&lt;/p&gt;

&lt;p&gt;For example, what is wrong with this &lt;code&gt;if&lt;/code&gt; check?&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="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;aString&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* do stuff */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's assuming that &lt;code&gt;aString&lt;/code&gt; has been initialized. If a string is not initialized, it will be &lt;code&gt;null&lt;/code&gt;! Calling &lt;code&gt;.equals()&lt;/code&gt; on a &lt;code&gt;null&lt;/code&gt; object is not going to end well.  This happens more often than you might expect.  It is better to write this:&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="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"yes"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;aString&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* do stuff */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I edited a POJO recently that was meant to represent a deserialized JSON object. The business requirements said I needed to remove any leading or trailing whitespace.  Thankfully, the &lt;code&gt;String.trim()&lt;/code&gt; method can do this for me in a single line!  I placed it in the setter like this:&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;Person&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&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;getFirstName&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="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstName&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;void&lt;/span&gt; &lt;span class="nf"&gt;setFirstName&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;firstName&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;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;trim&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;Seems innocent enough. 😉&lt;/p&gt;

&lt;p&gt;Imagine my frustration when converting a JSON to this object was throwing a &lt;code&gt;com.fasterxml.jackson.databind.JsonMappingException&lt;/code&gt; with a not-so-helpful explanation of "N/A".  What was happening???&lt;/p&gt;

&lt;p&gt;Apparently, if &lt;code&gt;firstName&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt; in JSON, &lt;code&gt;setFirstName(firstName)&lt;/code&gt; was calling &lt;code&gt;trim()&lt;/code&gt; on a &lt;code&gt;null&lt;/code&gt; object!&lt;/p&gt;

&lt;p&gt;What I need to do is check to make sure that the String parameter in &lt;code&gt;setFirstName(firstName)&lt;/code&gt; is not null. There's more than one way to check, but I chose a ternary operator:&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;Person&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&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;getFirstName&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="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstName&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;void&lt;/span&gt; &lt;span class="nf"&gt;setFirstName&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;firstName&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;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;firstName&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="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;firstName&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;trim&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;How about you? Have you run into the dreaded &lt;code&gt;NullPointerException&lt;/code&gt; recently? How did you fix it?&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>java</category>
      <category>junit</category>
      <category>spring</category>
    </item>
  </channel>
</rss>
