<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Java on BradCypert.com</title>
    <link>https://www.bradcypert.com/tags/java/</link>
    <description>Recent content in Java on BradCypert.com</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 27 Dec 2022 22:25:45 -0500</lastBuildDate>
    <atom:link href="https://www.bradcypert.com/tags/java/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A Beginner&#39;s Guide to Java Enums</title>
      <link>https://www.bradcypert.com/a-beginners-guide-to-java-enums/</link>
      <pubDate>Mon, 05 Aug 2019 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/a-beginners-guide-to-java-enums/</guid>
      <description>&lt;p&gt;An Enum in Java is a special data type that encompasses a set of predefined constants. When setting a variable of that Enum type, you have to use one of the constants that you define for it. A great example is the compass:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#8be9fd;font-style:italic&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#8be9fd;font-style:italic&#34;&gt;enum&lt;/span&gt; Compass {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  NORTH, EAST, SOUTH, WEST;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Compass direction &lt;span style=&#34;color:#ff79c6&#34;&gt;=&lt;/span&gt; Compass.&lt;span style=&#34;color:#50fa7b&#34;&gt;NORTH&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the above example, we create a new enum and it’s predefined set of constants. Then we create a variable of that enum type, and assign it to one of the constants. Keep in mind that we can only set our direction to &lt;code&gt;Compass.NORTH&lt;/code&gt;, &lt;code&gt;Compass.SOUTH&lt;/code&gt;, &lt;code&gt;Compass.EAST&lt;/code&gt; , &lt;code&gt;Compass.WEST&lt;/code&gt; or &lt;code&gt;null&lt;/code&gt;. If we wanted to set our direction to an inter-cardinal direction, we’ll have to add them to our enum, like so:&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Builder Design Pattern</title>
      <link>https://www.bradcypert.com/design-patterns-builder/</link>
      <pubDate>Tue, 24 Apr 2018 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/design-patterns-builder/</guid>
      <description>&lt;p&gt;Welcome back. I’m writing today to talk about something that I think is pretty cool — design patterns in code! Specifically, we’re going to cover the builder pattern, which I find myself using all the time when writing Android applications and sometimes when writing plain Java applications. Let’s setup a scenario: You have a class that has a constructor. You call it a &lt;code&gt;User&lt;/code&gt; class. The constructor for this class takes in a &lt;code&gt;String firstName&lt;/code&gt; and a &lt;code&gt;String lastName&lt;/code&gt;. You write some awesome logic in this class and use it everywhere. You new it up all over your codebase because it’s just &lt;strong&gt;that&lt;/strong&gt; good. You kick back and enjoy the good life, until you have another developer walk over to you and say &lt;em&gt;“Oh, hey. We need to add email address to the user class. And we’ll probably want to add phone number and mailing address, too.”&lt;/em&gt; Crap.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What the heck is Android&#39;s Proguard?</title>
      <link>https://www.bradcypert.com/what-the-heck-is-androids-proguard/</link>
      <pubDate>Wed, 21 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/what-the-heck-is-androids-proguard/</guid>
      <description>&lt;p&gt;Hello there Android developer or curious onlooker. Welcome back to another blog post talking about your favorite, my favorite, and &lt;a href=&#34;https://www.statista.com/statistics/266136/global-market-share-held-by-smartphone-operating-systems/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;the world’s favorite mobile operating system&lt;/a&gt;&#xA;. Today we’re going to talk about Proguard and what that means for Android Developers.&lt;/p&gt;&#xA;&lt;p&gt;Proguard is a free tool that has recently became pretty mainstream in the Android ecosystem. In fact, you’ve probably seen it’s name mentioned a few times in Android Studio (provided you’re using Android Studio), but what does it do? Proguard helps developers by shrinking, optimizing, obfuscating, and preverifying your Java class files. It’ll take care of some helpful tidbits like removing unused classes, methods, fields and attributes as well as unused instructions (Dead Code). Additionally, it takes care of optimizing your bytecode for you and renaming your classes, fields, and methods to extremely short and meaningless names. The two main purposes of Proguard are to make your Android application more performant and make it more difficult to reverse engineer.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A Brief Introduction to Tries</title>
      <link>https://www.bradcypert.com/a-brief-introduction-to-tries/</link>
      <pubDate>Fri, 30 Jun 2017 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/a-brief-introduction-to-tries/</guid>
      <description>&lt;p&gt;Hello there! Welcome back! Today I’m talking about Tries (pronounced “trys”). Tries are a type of search tree commonly used for storing and searching single characters that make up one or more strings. What make a trie interesting is that the first node contains an empty value and the descendants of a node have a common prefix associated with that node.&lt;/p&gt;&#xA;&lt;p&gt;Like most data structures, tries are easier to reason about when you have a picture to help explain it. Let’s take the word “propane” break it apart into a trie. Each character will be represented as a node.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Building RESTful APIs with Ginger, H2, and Java 8</title>
      <link>https://www.bradcypert.com/getting-started-with-ginger/</link>
      <pubDate>Thu, 01 Oct 2015 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/getting-started-with-ginger/</guid>
      <description>&lt;p&gt;Recently, I started writing a few RESTful services in Java Spark. I found a few recurring themes and decided to extract them out into a layer ontop of Spark to make it even easier to build a RESTful service from the ground up. This project is called Ginger and I’ll show you how to create a RESTful service using the Ginger framework.&lt;/p&gt;&#xA;&lt;p&gt;If you get stuck, the completed source code can be found &lt;a href=&#34;https://github.com/bradcypert/GingerSampleApp&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;here&lt;/a&gt;&#xA;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Intro to Reflection in Java</title>
      <link>https://www.bradcypert.com/intro-to-reflection-in-java/</link>
      <pubDate>Wed, 16 Sep 2015 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/intro-to-reflection-in-java/</guid>
      <description>&lt;p&gt;Recently, I began exploring an interesting idea I had – creating a RESTful framework built on top of Spark. Now, Spark is naturally restful, but I basically want the user to be able to define an object, flag it as a resource, and compile their code. They should then have &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, and &lt;code&gt;DELETE&lt;/code&gt; verbs available on that object. Sounds relatively trivial right?&lt;/p&gt;&#xA;&lt;p&gt;There are actually several ways to do this, but the simplest way (once I was able to wrap my head around it) involves metaprogramming, and specifically reflection. These can be naturally scary words, but it’s important to keep in mind, they’re both just programming.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
