<?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: Ricardo Caselati</title>
    <description>The latest articles on DEV Community by Ricardo Caselati (@ricardocaselati).</description>
    <link>https://dev.to/ricardocaselati</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%2F1099422%2Fce985ca2-87c1-4c84-98bc-c3ef505d3e4a.jpg</url>
      <title>DEV Community: Ricardo Caselati</title>
      <link>https://dev.to/ricardocaselati</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ricardocaselati"/>
    <language>en</language>
    <item>
      <title>Exploring While and DoWhile in Java: Master Loop Structures with Practical Examples</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Sat, 28 Dec 2024 13:46:06 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/exploring-while-and-dowhile-in-java-master-loop-structures-with-practical-examples-16od</link>
      <guid>https://dev.to/ricardocaselati/exploring-while-and-dowhile-in-java-master-loop-structures-with-practical-examples-16od</guid>
      <description>&lt;p&gt;This article will delve into two of Java's most fundamental programming structures: While and DoWhile loops. Understanding when and how to use them is essential for writing efficient code, solving dynamic problems, and manipulating data intelligently. Let’s explore their applications with practical examples.&lt;/p&gt;

&lt;p&gt;Previously in this series, we learned how to use the For loop in Java. Today, we will focus on While and DoWhile loops. How should you choose between these options in your daily programming tasks? Here's a tip: “Use the For loop when you know the required number of iterations. Use While when the number of iterations is unknown.”&lt;/p&gt;

&lt;p&gt;Let's get started with some code!&lt;/p&gt;

&lt;h2&gt;
  
  
  While Loop
&lt;/h2&gt;

&lt;p&gt;The following example demonstrates how a While loop iterates until a condition is satisfied. This is particularly useful when the exact number of iterations is not predetermined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class WhileExample {
    public static void main(String[] args) {
        int totalSubscribers = 100; // Example data
        int availableCoupons = 50;
        int currentSubscriber = 1;

        while (currentSubscriber &amp;lt;= availableCoupons) {
            // Print message that the subscriber won a coupon
            printMessage("Subscriber number " + currentSubscriber + " won a coupon!");
            // Increment the number of processed subscribers
            currentSubscriber++;
        }
    }

    static void printMessage(String message) {
        System.out.println(message);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we simulate a promotion where only the first 50 subscribers receive a discount coupon for a product. As long as currentSubscriber is less than or equal to the number of coupons, a message is printed in the terminal, and currentSubscriber is incremented by 1. This process continues until the condition is no longer met.&lt;/p&gt;

&lt;h2&gt;
  
  
  DoWhile Loop
&lt;/h2&gt;

&lt;p&gt;The logic for the DoWhile loop is similar to While but with one significant difference: the validation is performed at the end of the loop. In other words, the block of code executes first, and then the condition is checked. Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class WhileExample {
    public static void main(String[] args) {
        int totalSubscribers = 100; // Example data
        int availableCoupons = 50;
        int currentSubscriber = 1;

        while (currentSubscriber &amp;lt;= availableCoupons) {
            // Print message that the subscriber won a coupon
            printMessage("Subscriber number " + currentSubscriber + " won a coupon!");
            // Increment the number of processed subscribers
            currentSubscriber++;
        }
    }

    static void printMessage(String message) {
        System.out.println(message);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, a school tries to contact selected candidates for a course, with a maximum of three contact attempts. The line &lt;code&gt;answered = new Random().ints(0, 2).findFirst().getAsInt()&lt;/code&gt;; generates a random number using the &lt;code&gt;Random&lt;/code&gt; class. This number falls between 0 (inclusive) and 2 (exclusive), effectively simulating whether the candidate answered the call (1) or not (0). The process repeats until the candidate answers or the maximum attempts are reached.&lt;/p&gt;

&lt;p&gt;Both While and DoWhile loops are essential for scenarios such as validating user input, batch data processing, or algorithms requiring iteration until a specific condition is met. Examples include the school scenario above or loops for validating user inputs.&lt;/p&gt;

&lt;p&gt;We hope this article clarified the differences between While and DoWhile loops. How do you use these structures in your code? Share your experiences or questions in the comments! If you enjoyed this content, follow me for more articles in this series and other Java topics. See you next week—before the New Year—with more Java concepts!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Streamlining Restaurant Inventory Management: Challenges and Solutions</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Tue, 24 Dec 2024 18:48:54 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/streamlining-restaurant-inventory-management-challenges-and-solutions-1c2f</link>
      <guid>https://dev.to/ricardocaselati/streamlining-restaurant-inventory-management-challenges-and-solutions-1c2f</guid>
      <description>&lt;p&gt;Since September, I have been fully committed to this project, and one of the main challenges I encountered was: “How can we manage inventory more efficiently?"&lt;/p&gt;

&lt;p&gt;At first glance, this might seem straightforward. For example, if we’re talking about items like pens, it’s pretty simple: I have 10 pens, sell 2, and I’m left with 8. However, when it comes to running a restaurant, things get significantly more complex.&lt;/p&gt;

&lt;p&gt;Consider beans, for example. When I purchase 5 kg of beans, I also incorporate ingredients such as water, onions, garlic, and oil during the preparation. Moreover, we must factor in the portions served on-site compared to those prepared for takeout.&lt;/p&gt;

&lt;p&gt;To address these challenges, I developed a streamlined and functional workflow that starts with supplier registration.&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%2Fq5n5bkac7qgi7j8u34ga.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%2Fq5n5bkac7qgi7j8u34ga.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&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%2Fbvzzkcdau0h92y4ls8ug.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%2Fbvzzkcdau0h92y4ls8ug.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next comes the manufacturer registration process, allowing users to track which manufacturers offer the best quality or cost efficiency.&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%2Fyv1sqpsp5lcjeucm2ccn.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%2Fyv1sqpsp5lcjeucm2ccn.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&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%2Fl578haai8ivo1dsk4vm4.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%2Fl578haai8ivo1dsk4vm4.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following that is a critical feature of the application: purchase list creation. This step links market and manufacturer data to purchased products. For items without a specific manufacturer (like bulk potatoes, onions, etc.), the system is pre-configured with a "default manufacturer" labeled as "unknown/bulk." At this stage, we record details such as the purchase date, market, product, and manufacturer (when applicable).&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%2Fp1f0xms5lcnftbf1r3bf.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%2Fp1f0xms5lcnftbf1r3bf.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&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%2Fy1cin8qtpiv22z7gtpes.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%2Fy1cin8qtpiv22z7gtpes.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm returning to the initial challenge: how do you track ingredient usage while preparing dishes? The solution was to introduce a feature for recipe registration, enabling the system to calculate the average yield for each recipe automatically.&lt;/p&gt;

&lt;p&gt;When a recipe is created, it generates an item called a “Prepared Meal.” Based on configurations set in the "Settings" section, portion allocations are defined for each type of meal: dine-in or takeout. This way, one portion is deducted from the “Prepared Meals” inventory when a sale occurs.&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%2Fklsr48tt3mxeivbhye3d.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%2Fklsr48tt3mxeivbhye3d.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&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%2F3eemyzq59fwwyh0f2ky4.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%2F3eemyzq59fwwyh0f2ky4.png" alt="Image description" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There’s still plenty to refine, add, and improve, but this represents the progress so far.&lt;/p&gt;

&lt;p&gt;I welcome suggestions and constructive feedback! Wishing you all a Merry Christmas and a prosperous New Year!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Exploring the for Loop in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Mon, 16 Dec 2024 18:10:45 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/exploring-the-for-loop-in-java-4gnl</link>
      <guid>https://dev.to/ricardocaselati/exploring-the-for-loop-in-java-4gnl</guid>
      <description>&lt;p&gt;The for loop is one of the most popular structures for creating repetitions in Java. Unlike &lt;code&gt;while&lt;/code&gt;, which continues as long as a condition is true, the &lt;code&gt;for&lt;/code&gt; loop is ideal when you know exactly how many times the loop will run. This predictability makes managing counters and other conditions much easier. Let’s explore some practical examples together!&lt;/p&gt;

&lt;p&gt;Here’s a classic example: a simple counter that goes from 1 to 10, printing each number to the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int number = 1; number &amp;lt;= 10; number++) {
    System.out.println("Current number is: " + number);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the loop starts with the value 1, continues as long as the number is less than or equal to 10, and increments the value with each iteration. It’s a straightforward and efficient way to handle repetitions!&lt;/p&gt;

&lt;p&gt;Beyond counters, the &lt;code&gt;for&lt;/code&gt; loop is perfect for navigating arrays. Imagine you need to print the names of students in a class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String[] students = { "Marc", "John", "Layla", "Peter" };
for (int i = 0; i &amp;lt; students.length; i++) {
    System.out.println("Student " + (i + 1) + ": " + students[i]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the loop goes through each element in the array using the index to access their values.&lt;/p&gt;

&lt;p&gt;You can use the 'for-each' loop for an even more elegant and readable way to iterate through arrays. This is perfect when you want to access each element directly without worrying about indices.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String[] students = { "Marc", "John", "Layla", "Peter" };
for (String student : students) {
    System.out.println("Student: " + student);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the code automatically iterates through all array elements, assigning each to the &lt;code&gt;student&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;Fun fact: there are multiple ways to declare and initialize arrays in Java. Here are two common approaches:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Declaration with predefined values:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String[] names = { "Annie", "Buck", "Charlie" };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Declaration with a fixed size, adding values later:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int[] numbers = new int[5];
numbers[0] = 10;
numbers[1] = 20;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you already know the values, use the first approach. If the data will be defined later, the second option is more flexible!&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;for&lt;/code&gt; loop is a powerful ally in Java development. With it, you can create efficient loops and navigate arrays with ease. Practice using it in different scenarios and discover its potential!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus Tip&lt;/strong&gt;: Experiment with various conditions and observe how they affect the loop's behavior. Practice makes perfect in programming!&lt;/p&gt;

</description>
      <category>java</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Exploring Conditional Structures in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Fri, 13 Dec 2024 17:21:50 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/exploring-conditional-structures-in-java-3f2j</link>
      <guid>https://dev.to/ricardocaselati/exploring-conditional-structures-in-java-3f2j</guid>
      <description>&lt;p&gt;Today, let’s dive into conditional structures in Java, like IF / ELSE. These are used to define different execution paths based on boolean conditions. To make it practical, we’ll explore an example of a system that evaluates a student’s final grade and determines whether they are &lt;strong&gt;&lt;code&gt;APPROVED&lt;/code&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;code&gt;FAILED&lt;/code&gt;&lt;/strong&gt;. Oh, I’ll only show code snippets here without the complete class, so take this opportunity to practice creating classes (organized into packages) and main methods to run the examples. If you’re unsure, refer to previous lessons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Simple approval or failure&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;double finalGrade = 7.5;
String result = "UNDEFINED";

if (finalGrade &amp;gt;= 7) {
    result = "APPROVED";
} else {
    result = "FAILED";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the program checks if the grade is greater than or equal to 7.0. If true, it outputs "APPROVED"; otherwise, "FAILED."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Adding an intermediate condition&lt;/strong&gt;&lt;br&gt;
What if we want to include a third scenario, like the possibility of an extra exam for students with grades between 6.0 and 6.9? We can use &lt;strong&gt;else if&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;double finalGrade = 6.0;
String result = "UNDEFINED";

if (finalGrade &amp;gt;= 7) {
    result = "APPROVED";
} else if (finalGrade &amp;gt;= 6.0) {
    result = "EXTRA EXAM REQUIRED";
} else {
    result = "FAILED";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the program identifies three scenarios: approved students, those who need to take an extra exam, and those who fail. This type of structure is beneficial for systems requiring decisions based on multiple conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Practicing conditional structures is essential for anyone learning Java. They form the foundation of many logic-based solutions in everyday development. So, roll up your sleeves and explore various scenarios with &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else if&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt;! Happy coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Understanding Strings and Arrays in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Wed, 11 Dec 2024 12:49:12 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/understanding-strings-and-arrays-in-java-1m1f</link>
      <guid>https://dev.to/ricardocaselati/understanding-strings-and-arrays-in-java-1m1f</guid>
      <description>&lt;h2&gt;
  
  
  Strings in Java
&lt;/h2&gt;

&lt;p&gt;In this guide, we’ll explore how to handle text in Java using the &lt;code&gt;String&lt;/code&gt; class. Contrary to what one might assume, &lt;code&gt;String&lt;/code&gt; is not a primitive data type but a specialized class designed to work with text, offering unique features for efficient text management.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;String&lt;/code&gt; class is part of the &lt;code&gt;java.lang&lt;/code&gt; package and is in the JRE and JDK by default. A &lt;code&gt;String&lt;/code&gt; object’s default value is &lt;code&gt;null&lt;/code&gt;, consistent with the initialization behavior of all non-primitive types in Java.&lt;/p&gt;

&lt;p&gt;Here’s a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class StringObjects {
    public static void main(String[] args) {
        String text = "Learning Java!";
        String numbers = "12345";
        String character = "a";
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Notes:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Strings are initialized with double quotes (&lt;code&gt;"&lt;/code&gt;), unlike the char type, which uses single quotes (&lt;code&gt;'&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Strings in Java are defined using the keyword &lt;code&gt;String&lt;/code&gt;, which always starts with an uppercase "S."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To combine multiple strings, use the concatenation operator (&lt;code&gt;+&lt;/code&gt;), as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class StringObjects {
    public static void main(String[] args) {
        String text = "Learning Java!";
        String numbers = "12345";
        String character = "a";
        String finalText = text + " " + numbers + " " + character;

        System.out.println(finalText);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To reassign a new value to a string, you can simply overwrite it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class StringObjects {
    public static void main(String[] args) {
        String text = "Learning Java!";
        text = "Now learning C#!";

        System.out.println(text);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Arrays in Java
&lt;/h2&gt;

&lt;p&gt;Arrays are data structures that store collections of elements, all of the same type. The size of an array must be defined at creation, and each element within the array is accessed via its index.&lt;/p&gt;

&lt;p&gt;Here’s an example of an integer array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Arrays {
    public static void main(String[] args) {
        int[] numbers = new int[5];
        numbers[0] = 10;
        numbers[1] = 20;
        numbers[2] = 30;
        numbers[3] = 40;
        numbers[4] = 50;

        System.out.println(numbers[2]); // Outputs 30
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Notes:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Arrays in Java start at index &lt;code&gt;0&lt;/code&gt; and end at &lt;code&gt;length - 1&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you try to access an index beyond the array’s bounds (e.g., &lt;code&gt;numbers[5]&lt;/code&gt; in the example above), you’ll encounter an &lt;code&gt;ArrayIndexOutOfBoundsException&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Multidimensional Arrays and More
&lt;/h2&gt;

&lt;p&gt;Java also supports multidimensional arrays, often referred to as matrices. Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MultiDimensionalArrays {
    public static void main(String[] args) {
        int[][] matrix = new int[2][3];
        matrix[0][0] = 5;
        matrix[1][2] = 15;

        String[] words = {"Learning", "Java", "is", "fun!"};

        System.out.println(matrix[0][0]); // Outputs 5
        System.out.println(matrix[1][2]); // Outputs 15
        System.out.println(words[0] + " " + words[1]); // Outputs "Learning Java"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Exploring Non-Primitive Types in Java: A Dive into Object-Oriented Programming</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Tue, 10 Dec 2024 15:12:28 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/exploring-non-primitive-types-in-java-a-dive-into-object-oriented-programming-4b50</link>
      <guid>https://dev.to/ricardocaselati/exploring-non-primitive-types-in-java-a-dive-into-object-oriented-programming-4b50</guid>
      <description>&lt;p&gt;If you've ever dived into Java, you’re probably familiar with primitive types—they're like the simple building blocks of the language: straightforward, efficient, and perfect for storing basic values like numbers and true/false statements. But what if you're looking to create something a bit more intricate, like a banking system or a fun game? That’s where non-primitive types come into play, bringing a wonderful extra layer of complexity and creativity to your projects!&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Non-Primitive Types?
&lt;/h2&gt;

&lt;p&gt;Non-primitive types, also known as reference types, are used to create objects, arrays, or even custom classes. Unlike primitive types, they are not limited to storing data—they can encapsulate methods and properties, allowing for more dynamic and realistic programming.&lt;/p&gt;

&lt;p&gt;For example, consider a &lt;code&gt;BankAccount&lt;/code&gt; class. It might include attributes like &lt;code&gt;balance&lt;/code&gt; and methods for depositing money or converting currencies. To use this class, you instantiate it with the &lt;code&gt;new&lt;/code&gt; keyword, creating an object ready for use in your program.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Bank {
    public static void main(String[] args) {
        BankAccount account = new BankAccount(1000);
        account.deposit(500);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the &lt;code&gt;BankAccount&lt;/code&gt; object is initialized with a balance of $1000, and $500 is added using the class's &lt;code&gt;deposit&lt;/code&gt; method.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Role of Constructors
&lt;/h2&gt;

&lt;p&gt;Constructors are special methods in Java designed to initialize objects. They prepare an instance of a class for use, and they can even accept parameters to customize how objects are initialized:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class BankAccount {
    double balance;

    public BankAccount(double initialBalance) {
        this.balance = initialBalance;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using a constructor, you ensure that every object is properly set up right from the start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Non-Primitive Types?
&lt;/h2&gt;

&lt;p&gt;Non-primitive types open the door to powerful programming possibilities, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Organizing and structuring data efficiently;&lt;/li&gt;
&lt;li&gt;Representing complex, real-world concepts;&lt;/li&gt;
&lt;li&gt;Reusing code and enhancing the scalability of your applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By understanding and utilizing non-primitive types, you’ll be ready to harness the full potential of Object-Oriented Programming and build solutions that are both elegant and functional.&lt;/p&gt;

&lt;p&gt;So, why wait? The Java ecosystem is brimming with opportunities to bring your ideas to life!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Types: char and boolean</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Mon, 09 Dec 2024 12:31:53 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/types-char-and-boolean-4co6</link>
      <guid>https://dev.to/ricardocaselati/types-char-and-boolean-4co6</guid>
      <description>&lt;p&gt;After learning about the &lt;code&gt;double&lt;/code&gt; and &lt;code&gt;float&lt;/code&gt; types, it’s time to dive into two other essential primitive types in Java: &lt;code&gt;char&lt;/code&gt; and &lt;code&gt;boolean&lt;/code&gt;. Ready to explore?&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;char&lt;/code&gt; Type
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;char&lt;/code&gt; type is ideal for representing a single Unicode character. This means you can store any character—letters, numbers, or symbols—using it. There are two ways to assign a value to a &lt;code&gt;char&lt;/code&gt; variable:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using single quotes&lt;/strong&gt;, like &lt;code&gt;'A'&lt;/code&gt;, &lt;code&gt;'Ω'&lt;/code&gt;, or &lt;code&gt;'B'&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using a numeric value&lt;/strong&gt;, corresponding to the character in the Unicode table. For example, the code below stores the letter "A" using its Unicode value:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char letterA = 65;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to see &lt;code&gt;char&lt;/code&gt; in action? Check out this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class PrimitiveTypes {
    public static void main(String[] args) {
        char letterA = 'a';
        char capitalA = 'A';
        System.out.println(letterA); // a
        System.out.println(capitalA); // A
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The &lt;code&gt;boolean&lt;/code&gt; Type
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;boolean&lt;/code&gt; type is one of the simplest—and most useful! It represents &lt;strong&gt;only two possible values&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;true&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;false&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This variable type is essential for &lt;strong&gt;making decisions and controlling the program's flow&lt;/strong&gt;, especially with conditionals like &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt;. In Java, unlike some other languages where &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; are used to represent false and true, we explicitly use &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;An interesting detail is that &lt;code&gt;boolean&lt;/code&gt; variables often have names that resemble questions. Internationally, they typically start with "is," while in some contexts, prefixes like "eh" might be used. Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class PrimitiveTypes {
    public static void main(String[] args) {
        boolean isJavaFun = true; // Examples: isRunning, isActive
        boolean isAdult = false; // Examples: isTrue, isReady
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that you know how these types work, you can use them to make your code more intuitive and functional! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>java</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding float and double in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Sat, 07 Dec 2024 13:29:19 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/understanding-float-and-double-in-java-hoa</link>
      <guid>https://dev.to/ricardocaselati/understanding-float-and-double-in-java-hoa</guid>
      <description>&lt;p&gt;When diving deeper into Java’s data types, it's essential to understand &lt;code&gt;float&lt;/code&gt; and &lt;code&gt;double&lt;/code&gt;. These are floating-point data types used for real numbers, allowing for precision in handling both tiny and massive values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;float&lt;/code&gt;: Compact and efficient, perfect for lightweight tasks. It requires adding an &lt;code&gt;f&lt;/code&gt; at the end of the number to explicitly mark it as a &lt;code&gt;float&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;double&lt;/code&gt;: As the name suggests, it has &lt;em&gt;double the precision&lt;/em&gt; of &lt;code&gt;float&lt;/code&gt;, making it ideal for complex calculations and scenarios where precision matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Points:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Java interprets a number like &lt;code&gt;1.5&lt;/code&gt; as &lt;code&gt;double&lt;/code&gt; by default. To use a &lt;code&gt;float&lt;/code&gt;, append an &lt;code&gt;f&lt;/code&gt; (e.g., &lt;code&gt;1.5f&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;float&lt;/code&gt; stores fewer decimal places than &lt;code&gt;double&lt;/code&gt;, which is better for high-precision needs.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Example with float:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class FloatExample {
    public static void main(String[] args) {
        float numA = -101.23f;
        float numB = 2.356f;
        System.out.println(numA + numB); // Output: -98.874
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example with double:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class DoubleExample {
    public static void main(String[] args) {
        double valueOne = 0.5; // Implicitly a double
        double valueTwo = 0.5d; // Explicitly a double
        double valueThree = 0.123456789; // High precision
        System.out.println(valueOne);    // Output: 0.5
        System.out.println(valueTwo);    // Output: 0.5
        System.out.println(valueThree);  // Output: 0.123456789
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Choose One Over the Other?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Choose &lt;code&gt;float&lt;/code&gt; when memory is limited and calculations are less precise.&lt;/li&gt;
&lt;li&gt;Choose &lt;code&gt;double&lt;/code&gt; for scientific calculations or applications needing high precision.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>New Features in React 19: Transforming the Development Experience</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Fri, 06 Dec 2024 16:14:16 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/new-features-in-react-19-transforming-the-development-experience-4ahm</link>
      <guid>https://dev.to/ricardocaselati/new-features-in-react-19-transforming-the-development-experience-4ahm</guid>
      <description>&lt;p&gt;&lt;a href="https://react.dev/blog/2024/12/05/react-19" rel="noopener noreferrer"&gt;&lt;strong&gt;Learn more on the official site&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React 19 arrives with a series of innovations that make development faster and smarter. Among the key changes are Actions, which automate common tasks such as managing pending states, optimistic updates, and error handling in forms. Additionally, the introduction of new hooks and APIs, such as &lt;code&gt;useActionState&lt;/code&gt;, &lt;code&gt;useOptimistic&lt;/code&gt;, and the groundbreaking &lt;code&gt;use&lt;/code&gt;, provides greater control and simplification in application development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Actions: Simplifying Data Mutation
&lt;/h2&gt;

&lt;p&gt;Before React 19, handling pending states and errors required manual implementations. Now, with Actions, this process has been simplified. Asynchronous functions can automatically manage states, whether during form submissions or optimistic updates. The new &lt;code&gt;useActionState&lt;/code&gt; hook encapsulates errors, pending states, and actions into a single function. Additionally, native support for the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element makes form submission and automatic reset easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimistic Updates with &lt;code&gt;useOptimistic&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;To make interfaces more responsive, the &lt;code&gt;useOptimistic&lt;/code&gt; hook allows provisional results to be shown while asynchronous requests are pending. This enhances the user experience by displaying immediate changes and automatically reverting them in case of failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;use&lt;/code&gt;: Unprecedented Flexibility
&lt;/h2&gt;

&lt;p&gt;The new &lt;code&gt;use&lt;/code&gt; API introduces an innovative approach to consume promises and contexts directly in the render. Unlike traditional hooks, &lt;code&gt;use&lt;/code&gt; can be called conditionally, making it a powerful tool for handling dynamic resources and data.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Server Components and Server Actions
&lt;/h2&gt;

&lt;p&gt;React Server Components allow components to be processed on the server before sending them to the client, optimizing performance and resource usage. Complementing this, Server Actions enable client-side components to trigger asynchronous functions on the server, fostering smoother integration between the front-end and back-end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Static APIs for Site Generation
&lt;/h2&gt;

&lt;p&gt;New APIs, such as &lt;code&gt;prerender&lt;/code&gt; and &lt;code&gt;prerenderToNodeStream&lt;/code&gt;, increase efficiency in generating static HTML by waiting for data to be fully loaded before rendering.&lt;/p&gt;

&lt;p&gt;These changes solidify React 19 as one of the most powerful frameworks for web development, balancing simplicity with robustness.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other New Features in React 19:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ref as a Prop&lt;/strong&gt;: You can now pass a &lt;code&gt;ref&lt;/code&gt; as a property directly to functional components, simplifying the code and eliminating the need for &lt;code&gt;forwardRef&lt;/code&gt;. An automatic migration tool will be available to assist with this change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improvements in Hydration Errors&lt;/strong&gt;: React has enhanced hydration error detection, offering detailed messages and clear diffs between the content rendered on the server and the client, making it easier to diagnose incompatibilities.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;**&amp;lt;Context&amp;gt;**&lt;/code&gt; as a Provider: You can now use &lt;code&gt;&amp;lt;Context&amp;gt;&lt;/code&gt; directly as a provider, simplifying the use of contexts without the need for &lt;code&gt;&amp;lt;Context.Provider&amp;gt;&lt;/code&gt;. A migration tool will also be available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleanup Functions for Refs&lt;/strong&gt;: Ref callbacks can now return a cleanup function, allowing you to manage references when the component is unmounted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Initial Value in &lt;code&gt;useDeferredValue&lt;/code&gt;&lt;/strong&gt;: The &lt;code&gt;useDeferredValue&lt;/code&gt; hook now supports an initial value, useful for scenarios like search, improving the experience during initial renders and updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native Support for Document Metadata&lt;/strong&gt;: React now allows metadata tags like &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; to be managed directly within components, simplifying the management of these tags in the document’s &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Styles and Stylesheets&lt;/strong&gt;: React has introduced integrated control for stylesheets, allowing precise management of loading order and precedence, ensuring stylesheets are loaded before dependent content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support for Asynchronous Scripts&lt;/strong&gt;: Asynchronous scripts can now be rendered directly within components. React handles deduplication and loading, even across multiple script renders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Preloading APIs&lt;/strong&gt;: New APIs such as &lt;code&gt;prefetchDNS&lt;/code&gt;, &lt;code&gt;preconnect&lt;/code&gt;, &lt;code&gt;preload&lt;/code&gt;, and &lt;code&gt;preinit&lt;/code&gt; optimize the initial loading and updates on the client, improving user experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility with Third-Party Scripts and Extensions&lt;/strong&gt;: React now ignores unexpected tags inserted into the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; by scripts and extensions, preventing hydration errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Error Reporting&lt;/strong&gt;: Errors captured by error boundaries are now reported only once, with detailed information about their origin, eliminating log duplication.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>news</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Variables and Data Types in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Thu, 05 Dec 2024 17:10:37 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/variables-and-data-types-in-java-410l</link>
      <guid>https://dev.to/ricardocaselati/variables-and-data-types-in-java-410l</guid>
      <description>&lt;p&gt;In Java, a strongly-typed and statically-typed language, the data we use in code has well-defined types. This means you must declare the data type when creating a variable.&lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int answerToEverything = 42;
System.out.println(answerToEverything);

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

&lt;/div&gt;



&lt;p&gt;Here, the variable &lt;code&gt;answerToEverything&lt;/code&gt; is of type &lt;code&gt;int&lt;/code&gt;, meaning it can only store integer values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Primitive and Non-Primitive Types
&lt;/h2&gt;

&lt;p&gt;Java data types are categorized into primitive and non-primitive types. Primitive types include &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;byte&lt;/code&gt;, and &lt;code&gt;boolean&lt;/code&gt;, while non-primitive types are used to represent objects and more complex structures, such as classes and arrays.&lt;br&gt;
An important distinction is that primitive types store values directly, while non-primitive types store references to the data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Details of Primitive Types
&lt;/h2&gt;

&lt;p&gt;Primitive types are essential for storing simple data and performing fast operations. Each has a specific size and range:&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%2Fjko3q5vc3ndinryy81yk.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%2Fjko3q5vc3ndinryy81yk.png" alt="Image description" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;They are ideal for numerical calculations and manipulations. A practical example of using &lt;code&gt;byte&lt;/code&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;byte age = 25;
System.out.println(age);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage Tips
&lt;/h2&gt;

&lt;p&gt;Use consistent types in operations (e.g., avoid mixing &lt;code&gt;int&lt;/code&gt; with &lt;code&gt;short&lt;/code&gt;).&lt;br&gt;
For numbers larger than &lt;code&gt;int&lt;/code&gt;, use &lt;code&gt;long&lt;/code&gt; with the suffix &lt;code&gt;L&lt;/code&gt; at the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;long population = 7_900_000_000L;
System.out.println(population);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java allows underscores (_) to improve the readability of large numbers, as shown above. This feature was introduced in Java 7 and does not affect the actual value of the number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pro Tip
&lt;/h2&gt;

&lt;p&gt;Always prefer an uppercase &lt;code&gt;L&lt;/code&gt; for &lt;code&gt;long&lt;/code&gt; suffixes to avoid confusion with the number &lt;code&gt;1&lt;/code&gt;, especially in fonts where the two characters look similar.&lt;/p&gt;

&lt;p&gt;This practical and structured approach to data types helps create more efficient and readable programs!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Exploring Class Organization with Packages in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Tue, 03 Dec 2024 16:05:42 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/exploring-class-organization-with-packages-in-java-1cg5</link>
      <guid>https://dev.to/ricardocaselati/exploring-class-organization-with-packages-in-java-1cg5</guid>
      <description>&lt;p&gt;In the Java world, organization is key, and packages play a vital role in achieving it. Packages act as virtual directories that group classes, making your projects more structured and scalable.&lt;/p&gt;

&lt;p&gt;When you create a class without specifying a package, it resides in the default package. However, by using named packages like &lt;code&gt;com.example.project&lt;/code&gt;, you not only improve your code organization but also adhere to Java’s common best practices. The package name reflects the directory structure—for instance, &lt;code&gt;com.example.project&lt;/code&gt; indicates that the class is located in &lt;code&gt;src/com/example/project/&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Access Classes from Other Packages?
&lt;/h2&gt;

&lt;p&gt;This is where the &lt;code&gt;import&lt;/code&gt; statement comes in. It allows you to use external classes in your code, either broadly (&lt;code&gt;import package.*&lt;/code&gt;) or specifically (&lt;code&gt;import package.Class&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.myProject.helloworld;  
import java.lang.*;  
import java.lang.Math;  

public class SquareRootOfTwentyFive {  
    public static void main(String[] args) {  
        System.out.println("The square root of twenty-five is:");  
        System.out.println(Math.sqrt(25));  
    }  
}  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, to use mathematical methods like &lt;code&gt;Math.sqrt(25)&lt;/code&gt;, you simply need to import the &lt;code&gt;java.lang.Math&lt;/code&gt; class, one of Java's many utility classes. This functionality enhances modularity and reusability, which are crucial for building robust and collaborative projects.&lt;/p&gt;

&lt;p&gt;Let Java's package system guide your project structure toward clean, scalable, and professional code.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Exploring Classes and the Main Method in Java</title>
      <dc:creator>Ricardo Caselati</dc:creator>
      <pubDate>Mon, 02 Dec 2024 13:55:24 +0000</pubDate>
      <link>https://dev.to/ricardocaselati/exploring-classes-and-the-main-method-in-java-33go</link>
      <guid>https://dev.to/ricardocaselati/exploring-classes-and-the-main-method-in-java-33go</guid>
      <description>&lt;p&gt;If you're new to Java, it's important to know that classes and the special method &lt;code&gt;public static void main&lt;/code&gt; are key to creating any program. Let’s dive into how they work in a practical and straightforward way!&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Classes in Java?
&lt;/h2&gt;

&lt;p&gt;Classes are the building blocks of Java programs. They act as blueprints containing methods (or functions) that perform specific tasks. Imagine you're building a house: the blueprint represents the class, and the functional rooms are the methods that bring the house to life.&lt;/p&gt;

&lt;p&gt;For example, a library system class might include methods for borrowing and returning books. However, to use these methods, you first need to create an object based on the class—just like you need to build the house before living in it.&lt;/p&gt;

&lt;p&gt;Creating a class is simple. Use the &lt;code&gt;class&lt;/code&gt; keyword, 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;public class HelloWorld {

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

&lt;/div&gt;



&lt;p&gt;Keep in mind that in most cases, the class name should match the filename, as shown in the example above.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Starting Point: &lt;code&gt;public static void main&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Every Java program begins with the &lt;code&gt;main&lt;/code&gt; method, which acts as the program’s entry point. This special method is required (except in libraries) and must be included within a class. Here's how it looks in the &lt;code&gt;HelloWorld&lt;/code&gt; class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HelloWorld {

  public static void main(String[] args) {
    // The program starts executing here
  }

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

&lt;/div&gt;



&lt;p&gt;You can have multiple classes, each with its own &lt;code&gt;main&lt;/code&gt; method. This allows the program to start from different points, depending on your IDE settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Displaying Messages in the Console
&lt;/h2&gt;

&lt;p&gt;To output messages in the console, you can use the &lt;code&gt;System.out.println()&lt;/code&gt; or &lt;code&gt;System.out.print()&lt;/code&gt; commands. What’s the difference? &lt;code&gt;println&lt;/code&gt; adds a new line after the message, while &lt;code&gt;print&lt;/code&gt; keeps the cursor on the same line.&lt;/p&gt;

&lt;p&gt;Here’s an example using &lt;code&gt;println&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("First Line");
    System.out.println("Second Line");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And an example using &lt;code&gt;print&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HelloWorld {

  public static void main(String[] args) {
    System.out.print("First Line");
    System.out.print("This will also appear on the first line");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These tools are essential for beginners, helping you test and understand how your code behaves. So, roll up your sleeves, create a project in IntelliJ, try these examples, and watch the magic happen! 🚀&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>java</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
