Basics of Java

50 programs in this topic — each includes source code, sample output and explanation.

  1. Print Hello World

    A simple program that prints "Hello World" to the console, introducing the basic structure of a Java application.

  2. Print Your Name

    This program prints a personalized name to the console.

  3. Print Sum of Two Numbers

    This program demonstrates variables and arithmetic operations.

  4. Print Difference of Two Numbers

    This program prints the difference between two numbers.

  5. Print Product of Two Numbers

    This program prints the product of two numbers.

  6. Print Quotient of Two Numbers

    This program prints the quotient of two numbers.

  7. Print Remainder of Division

    This program prints the remainder when one number is divided by another.

  8. Print Concatenated Strings

    This program prints concatenated strings.

  9. Print Integer Variable

    This program prints the value of an integer variable to the console.

  10. Print Double Variable

    This program prints the value of a double variable to the console.

  11. Print Character Variable

    This program prints the value of a character variable.

  12. Print Boolean Variable

    This program prints the value of a boolean variable.

  13. Print String Variable

    This program prints the value of a string variable.

  14. Print Constant Value

    This program prints the value of a constant using the final keyword.

  15. Print Literal Values

    This program prints literal values directly.

  16. Print Multiple Variables

    This program prints multiple variables in one statement.

  17. Print Float Variable

    This program prints the value of a float variable.

  18. Print Long Variable

    This program prints the value of a long variable.

  19. Print Short Variable

    This program prints the value of a short variable.

  20. Print Byte Variable

    This program prints the value of a byte variable.

  21. Print Final Integer Constant

    This program prints the value of a final integer constant.

  22. Print Multiple Data Types Together

    This program prints integer, double, and string variables together.

  23. Print Text with Newline Escape Sequence

    This program demonstrates the newline escape sequence.

  24. Print Text with Tab Escape Sequence

    This program demonstrates the tab escape sequence.

  25. Print Text with Quotes

    This program demonstrates printing double quotes inside text.

  26. Print Formatted Decimal Value

    This program prints a decimal value formatted to two decimal places.

  27. Print Formatted String with Placeholders

    This program prints a string using placeholders.

  28. Print Integer Cast to Double

    This program demonstrates type casting from int to double.

  29. Print Double Cast to Integer

    This program demonstrates type casting from double to int.

  30. Print Character Cast to Integer

    This program demonstrates type casting from a character to its integer ASCII value.

  31. Print Result of Boolean Expression

    This program prints the result of a boolean expression.

  32. Concatenate Three Strings

    This program concatenates three strings and prints them.

  33. Print Backslash Character

    This program prints a backslash character using escape sequence.

  34. Print Currency Value

    This program prints a currency value formatted with two decimal places.

  35. Cast Integer to Character

    This program casts an integer to a character.

  36. Cast Float to Integer

    This program casts a float to an integer.

  37. Print Equality Check

    This program prints the result of an equality check.

  38. Print Logical AND Result

    This program prints the result of a logical AND operation.

  39. Print Logical OR Result

    This program prints the result of a logical OR operation.

  40. Print Logical NOT Result

    This program prints the result of a logical NOT operation.

  41. Print Integer and String Together

    This program prints an integer and a string together.

  42. Print Multiple Placeholders

    This program prints multiple variables using formatted placeholders.

  43. Print Backspace Escape Sequence

    This program demonstrates the backspace escape sequence.

  44. Print Single Quote Character

    This program prints a single quote character using escape sequence.

  45. Print Backslash and Quotes Together

    This program prints backslashes and quotes together.

  46. Cast Integer to Double Automatically

    This program demonstrates automatic type casting from int to double.

  47. Cast Double to Integer Explicitly

    This program demonstrates explicit type casting from double to int.

  48. Cast Char to Int

    This program demonstrates casting a char to int.

  49. Cast Int to Char

    This program demonstrates casting an int to char.

  50. Cast Double to Float

    This program demonstrates type casting from a double to a float.

Quick Links to Explore