Explanation
1. Purpose
This program demonstrates how to store different types of data (text, integers, and decimals) in variables and display them to the console combined with text.
2. Key Concepts
- Data Types:
Stringfor text.intfor whole numbers.doublefor decimal numbers.
- String Concatenation (
+operator): Joining literal text and variables together into a single message. - Console Output: Using
System.out.println()to print text to the screen, ending with a new line.
3. Code Walkthrough
- Lines 3–5 (Variables): Creates and initializes three variables:
course(stores text),lesson(stores an integer), andprogress(stores a decimal). - Line 6: Prints a basic greeting literal:
"Hello, Codinx Labs!". - Line 7: Combines the
coursetext, a separator (" - lesson "), and thelessonnumber, printing them together. - Line 8: Combines the label
"Progress: "with the numericprogressvalue.
4. Output
Hello, Codinx Labs!
Java fundamentals - lesson 1
Progress: 0.25