Basics of Java
50 programs in this topic — each includes source code, sample output and explanation.
-
Print Hello World
A simple program that prints "Hello World" to the console, introducing the basic structure of a Java application.
-
Print Your Name
This program prints a personalized name to the console.
-
Print Sum of Two Numbers
This program demonstrates variables and arithmetic operations.
-
Print Difference of Two Numbers
This program prints the difference between two numbers.
-
Print Product of Two Numbers
This program prints the product of two numbers.
-
Print Quotient of Two Numbers
This program prints the quotient of two numbers.
-
Print Remainder of Division
This program prints the remainder when one number is divided by another.
-
Print Concatenated Strings
This program prints concatenated strings.
-
Print Integer Variable
This program prints the value of an integer variable to the console.
-
Print Double Variable
This program prints the value of a double variable to the console.
-
Print Character Variable
This program prints the value of a character variable.
-
Print Boolean Variable
This program prints the value of a boolean variable.
-
Print String Variable
This program prints the value of a string variable.
-
Print Constant Value
This program prints the value of a constant using the final keyword.
-
Print Literal Values
This program prints literal values directly.
-
Print Multiple Variables
This program prints multiple variables in one statement.
-
Print Float Variable
This program prints the value of a float variable.
-
Print Long Variable
This program prints the value of a long variable.
-
Print Short Variable
This program prints the value of a short variable.
-
Print Byte Variable
This program prints the value of a byte variable.
-
Print Final Integer Constant
This program prints the value of a final integer constant.
-
Print Multiple Data Types Together
This program prints integer, double, and string variables together.
-
Print Text with Newline Escape Sequence
This program demonstrates the newline escape sequence.
-
Print Text with Tab Escape Sequence
This program demonstrates the tab escape sequence.
-
Print Text with Quotes
This program demonstrates printing double quotes inside text.
-
Print Formatted Decimal Value
This program prints a decimal value formatted to two decimal places.
-
Print Formatted String with Placeholders
This program prints a string using placeholders.
-
Print Integer Cast to Double
This program demonstrates type casting from int to double.
-
Print Double Cast to Integer
This program demonstrates type casting from double to int.
-
Print Character Cast to Integer
This program demonstrates type casting from a character to its integer ASCII value.
-
Print Result of Boolean Expression
This program prints the result of a boolean expression.
-
Concatenate Three Strings
This program concatenates three strings and prints them.
-
Print Backslash Character
This program prints a backslash character using escape sequence.
-
Print Currency Value
This program prints a currency value formatted with two decimal places.
-
Cast Integer to Character
This program casts an integer to a character.
-
Cast Float to Integer
This program casts a float to an integer.
-
Print Equality Check
This program prints the result of an equality check.
-
Print Logical AND Result
This program prints the result of a logical AND operation.
-
Print Logical OR Result
This program prints the result of a logical OR operation.
-
Print Logical NOT Result
This program prints the result of a logical NOT operation.
-
Print Integer and String Together
This program prints an integer and a string together.
-
Print Multiple Placeholders
This program prints multiple variables using formatted placeholders.
-
Print Backspace Escape Sequence
This program demonstrates the backspace escape sequence.
-
Print Single Quote Character
This program prints a single quote character using escape sequence.
-
Print Backslash and Quotes Together
This program prints backslashes and quotes together.
-
Cast Integer to Double Automatically
This program demonstrates automatic type casting from int to double.
-
Cast Double to Integer Explicitly
This program demonstrates explicit type casting from double to int.
-
Cast Char to Int
This program demonstrates casting a char to int.
-
Cast Int to Char
This program demonstrates casting an int to char.
-
Cast Double to Float
This program demonstrates type casting from a double to a float.