This content originally appeared on DEV Community and was authored by Cal Afun
Hey Guys, if you have been able to reach this far in the series, congratulations🥳🥂. Today, we are going to cover 3 different beginner-friendly tasks that are going to help us understand how to write code in Java. The first task has a demo code at the end for reference, but for the others, you would have to try them out and explore on your own.
If you feel like you want to get feedback on your code, you could email it to me at afuncal188@gmail.com, and I will be more than happy to assist you.
You should also note that the project also contain things that weren't covered in the series. This will help you appreciate the value of researching in programming. But they will be covered in future series!!!
NOTE
I will be giving a shout-out to the best performers of these projects in one of my blogs. To stand a chance, please complete the three projects yourself (no A.I.) with a readme file talking about all the mistakes you encountered and what you learnt from this.Place the three projects with the readme file and zip them together. Afterwards send them to my email; afuncal188@gmail.com. I urge you all to try it, as it is a wonderful learning experience.
Before we start the project these are just some things you should know/ remember so you don't get frustrated. As usual if you need clarification you can send me an email
Common Pitfalls When Learning Java Data Types
Forgetting the L or f suffix:
Java defaults whole numbers to int and decimals to double.
If your number is too big for int, you must add L for a long.
If you want a float, you must add f.
long bigNumber = 16_000_000_000L;
float pi = 3.14f;
Integer division by zero:
Doing 10 / 0 with int (or long) causes ArithmeticException.
But with floating-point (10.0 / 0), Java prints Infinity.
int x = 10 / 0; // ❌ ArithmeticException
double y = 10.0 / 0; // ✅ Prints Infinity
Confusion with char in arithmetic:
A char isn’t just a letter, it’s a number (its Unicode value).
So 'B' + 10 actually does math (66 + 10 = 76).
System.out.println('B' + 10); // 76
System.out.println("B" + 10); // B10
Forgetting System.out:
Students often write System.println(...) and get an error.
Remember: it’s always System.out.println(...).
System.out.println("Hello"); // ✅
Unexpected concatenation results:
The + operator works differently depending on types.
With numbers: it adds. With Strings: it concatenates.
Mixing them can give surprising results because evaluation goes left to right.
S
ystem.out.println(5 + 5 + "😭"); // output is 10😭
System.out.println("😭" + 5 + 5); // output is 😭55
Re-declaring variables with the same name:
You can’t declare two variables with the same name in the same method.
Example:
int num = 10;
long num = 100L; // ❌ Error: already defined
There are more common pitfalls a beginner would likely encounter writing these codes. But hey, coding can't be learn't without mistakes so take your time and ACE it.
Project 1: "My First Java Info Card"
Create a Java program that prints out an “info card” about yourself (or any imaginary character).
Requirements:
Use a main method to run the program.
Add comments to explain each part of your code (single-line and multi-line).
Declare different data types (e.g., String for name, int for age, double for height, char for grade, boolean for student status).
Print all the information neatly in the console.
Goal: Practice writing a full simple Java program that combines comments and data types.
Project 2: Emoji & Symbols Printer
Write a Java program that displays a “Poster” of special characters using Unicode values.
Create a title for your poster (e.g., "=== My Symbol Gallery ===").
Print at least 5 different special characters or emojis using their Unicode escape sequences (like \u2764 for ♥, \u2122 for ™, etc.).
Mix them with text — for example, print a heart next to your name, or ™ next to a brand name.
Add comments explaining which Unicode values you used and what each symbol represents.
💡 Bonus Challenge: Try arranging the characters into a simple shape (like a row of stars ★★★★ or a smiley face).
Project 3: Data Type Showcase
Create a Java class called DataTypeShowcase.
Inside the main method:
Declare and initialise one variable of each primitive type (byte, short, int, long, float, double, char, boolean).
Declare and initialise a String variable (non-primitive type).
Print the values of each variable with clear labels.
Perform and print the results of at least 5 operations that demonstrate how data types work. For example:
Add an int and a byte.
Multiply a float by a number.
Divide a double by another number.
Use a comparison to print a boolean result.
Format the output so it’s easy to read and understand (labels + values).
Demo Code for Project 1
public class project2 { // main class (filename must match!)
public static void main(String[] mylist) { // defining the main method
/*
The main method is static so the JVM can run it without
creating an instance of the class.
*/
String name = "Cal";
int age = 19;
double height = 2.5;
String grade = "A";
boolean isStudent = true; // note: Java uses lowercase true/false
/*
Printing values using concatenation (String + variable).
Always use double quotes for Strings (" "),
while single quotes (' ') are for characters (char).
*/
System.out.println("===== Student Info =====");
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Height: " + height);
System.out.println("Grade: " + grade);
} // end main
} // end class
/*
Alternative: You could also store grade as a char, e.g., char grade = 'A';
But if you need grades like B+ or A-, use a String instead,
since char only stores a single 16-bit character.
You could revisit any of my old blogs to properly understand these concepts if you have any confusion
You could also email me at afuncal188@gmail.com for any concerns you might have
*/
This content originally appeared on DEV Community and was authored by Cal Afun

Cal Afun | Sciencx (2025-08-19T17:51:32+00:00) From Hello World to Data Types: Your First Java Mini Project. Retrieved from https://www.scien.cx/2025/08/19/from-hello-world-to-data-types-your-first-java-mini-project/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.