The best way to learn Java programming is by practicing examples. The page contains examples on basic concepts of Java. You are advised to take the references from these examples and try them on your own.

All the programs on this page are tested and should work on all platforms.

  1. Java Program to Print an Integer (Entered by the User)
  2. Java Program to Add Two Integers
  3. Java Program to Multiply two Floating Point Numbers
  4. Java Program to Find ASCII Value of a character
  5. Java Program to Compute Quotient and Remainder
  6. Java Program to Swap Two Numbers
  7. Java Program to Check Whether a Number is Even or Odd
  8. Java Program to Check Whether an Alphabet is Vowel or Consonant
  9. Java Program to Find the Largest Among Three Numbers
  10. Java Program to Find all Roots of a Quadratic Equation
  11. Java Program to Check Leap Year
  12. Java Program to Check Whether a Number is Positive or Negative
  13. Java Program to Check Whether a Character is Alphabet or Not
  14. Java Program to Calculate the Sum of Natural Numbers
  15. Java Program to Find Factorial of a Number
  16. Java Program to Generate Multiplication Table
  17. Java Program to Display Fibonacci Series
  18. Java Program to Find GCD of two Numbers
  19. Java Program to Find LCM of two Numbers
  20. Java Program to Display Characters from A to Z using loop
  21. Java Program to Count Number of Digits in an Integer
  22. Java Program to Reverse a Number
  23. Java Program to Calculate the Power of a Number
  24. Java Program to Check Whether a Number is Palindrome or Not
  25. Java Program to Check Whether a Number is Prime or Not
  26. Java Program to Display Prime Numbers Between Two Intervals
  27. Java Program to Check Armstrong Number
  28. Java Program to Display Armstrong Number Between Two Intervals
  29. Java Program to Display Prime Numbers Between Intervals Using Function
  30. Java Program to Display Armstrong Numbers Between Intervals Using Function
  31. Java Program to Display Factors of a Number
  32. Java Program to Make a Simple Calculator Using switch...case
  33. Java Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers
  34. Java Program to Find the Sum of Natural Numbers using Recursion
  35. Java Program to Find Factorial of a Number Using Recursion
  36. Java Program to Find G.C.D Using Recursion
  37. Java Program to Convert Binary Number to Decimal and vice-versa
  38. Java Program to Convert Octal Number to Decimal and vice-versa
  39. Java Program to Convert Binary Number to Octal and vice-versa
  40. Java Program to Reverse a Sentence Using Recursion
  41. Java Program to calculate the power using recursion
  42. Java Program to Calculate Average Using Arrays
  43. Java Program to Find Largest Element of an Array
  44. Java Program to Calculate Standard Deviation
  45. Java Program to Add Two Matrix Using Multi-dimensional Arrays
  46. Java Program to Multiply to Matrix Using Multi-dimensional Arrays
  47. Java Program to Multiply two Matrices by Passing Matrix to a Function
  48. Java Program to Find Transpose of a Matrix
  49. Java Program to Find the Frequency of Character in a String
  50. Java Program to Count the Number of Vowels and Consonants in a Sentence
  51. Java Program to Sort Elements in Lexicographical Order (Dictionary Order)
  52. Java Program to Add Two Complex Numbers by Passing Class to a Function
  53. Java Program to Calculate Difference Between Two Time Periods
  54. Java Code To Create Pyramid and Pattern
  55. Java Program to Remove All Whitespaces from a String
  56. Java Program to Print an Array
  57. Java Program to Convert String to Date
  58. Java Program to Round a Number to n Decimal Places
  59. Java Program to Concatenate Two Arrays
  60. Java Program to Convert Character to String and Vice-Versa
  61. Java Program to Check if An Array Contains a Given Value
  62. Java Program to Check if a String is Empty or Null
  63. Java Program to Get Current Date/TIme
  64. Java Program to Convert Milliseconds to Minutes and Seconds
  65. Java Program to Add Two Dates
  66. Java Program to Join Two Lists
  67. Java Program to Convert the ArrayList to an array and vice versa
  68. Java Program to Get Current Working Directory
  69. Java Program to Convert Map (HashMap) to List
  70. Java Program to Convert Array to Set (HashSet) and Vice-Versa
  71. Java Program to Convert Byte Array to Hexadecimal
  72. Java Program to Create String from Contents of a File
  73. Java Program to Append Text to an Existing File
  74. Java Program to Convert a Stack Trace to a String
  75. Java Program to Convert File to byte array and Vice-Versa
  76. Java Program to Convert InputStream to String
  77. Java Program to Convert OutputStream to String
  78. Java Program to Lookup enum by String value
  79. Java Program to Compare Strings
  80. Java Program to Sort a Map By Values
  81. Java Program to Sort ArrayList of Custom Objects By Property
  82. Java Program to Check if a String is Numeric
  83. Java Program to Create Directories
  84. Java Program to Rename File
  85. Java Program to Get all Files Present in a Directory
  86. Java Program to Copy File
  87. Java Program to convert char type variables to int
  88. Java Program to convert int type variables to char
  89. Java Program to convert long type variables into int
  90. Java Program to convert int type variables to long
  91. Java Program to convert boolean variables into string
  92. Java Program to convert string type variables into boolean
  93. Java Program to convert string type variables into int
  94. Java Program to convert int type variables to String
  95. Java Program to convert int type variables to double
  96. Java Program to convert double type variables to int
  97. Java Program to convert string variables to double
  98. Java Program to convert double type variables to string
  99. Java Program to convert primitive types to objects and vice versa
  100. Java Program to Implement Bubble Sort algorithm
  101. Java Program to Implement Quick Sort Algorithm
  102. Java Program to Implement Merge Sort Algorithm
  103. Java Program to Implement Binary Search Algorithm
  104. Java Program to Call One Constructor from another
  105. Java Program to implement private constructors
  106. Java Program to pass lambda expression as a method argument
  107. Java Program to pass methods as arguments to other methods
  108. Java Program to Calculate the Execution Time of Methods
  109. Java Program to Convert a String into the InputStream
  110. Java Program to Convert the InputStream into Byte Array
  111. Java Program to Load File as InputStream
  112. Java Program to Create File and Write to the File
  113. Java Program to Read the Content of a File Line by Line
  114. Java Program to Delete File in Java
  115. Java Program to Delete Empty and Non-empty Directory
  116. Java Program to Get the File Extension
  117. Java Program to Get the name of the file from the absolute path
  118. Java Program to Get the relative path from two absolute paths
  119. Java Program to Count number of lines present in the file
  120. Java Program to Determine the class of an object
  121. Java Program to Create an enum class
  122. Java Program to Print object of a class
  123. Java Program to Create custom exception
  124. Java Program to Create a immutable class
  125. Java Program to Check if two strings are anagram
  126. Java Program to Compute all the permutations of the string
  127. Java Program to Create random strings
  128. Java Program to Clear the StringBuffer
  129. Java Program to Capitalize the first character of each word in a String
  130. Java Program to Iterate through each characters of the string.
  131. Java Program to Differentiate String == operator and equals() method
  132. Java Program to Implement switch statement on strings
  133. Java Program to Calculate simple interest and compound interest
  134. Java Program to Implement multiple inheritance
  135. Java Program to Determine the name and version of the operating system
  136. Java Program to Check if two of three boolean variables are true
  137. Java Program to Iterate over enum
  138. Java Program to Check the birthday and print Happy Birthday message
  139. Java Program to Implement LinkedList
  140. Java Program to Implement stack data structure
  141. Java Program to Implement the queue data structure
  142. Java Program to Get the middle element of LinkedList in a single iteration
  143. Java Program to Convert the LinkedList into an Array and vice versa
  144. Java Program to Convert the ArrayList into a string and vice versa
  145. Java Program to Iterate over an ArrayList
  146. Java Program to Iterate over a HashMap
  147. Java Program to Iterate over a Set
  148. Java Program to Merge two lists
  149. Java Program to Update value of HashMap using key
  150. Java Program to Remove duplicate elements from ArrayList
  151. Java Program to Get key from HashMap using the value
  152. Java Program to Detect loop in a LinkedList
  153. Java Program to Calculate union of two sets
  154. Java Program to Calculate the intersection of two sets
  155. Java Program to Calculate the difference between two sets
  156. Java Program to Check if a set is the subset of another set
  157. Java Program to Sort map by keys
  158. Java Program to Pass ArrayList as the function argument
  159. Java Program to Iterate over ArrayList using Lambda Expression
  160. Java Program to Implement Binary Tree Data Structure
  161. Java Program to Perform the preorder tree traversal
  162. Java Program to Perform the postorder tree traversal
  163. Java Program to Perform the inorder tree traversal
  164. Java Program to Count number of leaf nodes in a tree
  165. Java Program to Check if a string contains a substring
  166. Java Program to Access private members of a class
  167. Java Program to Check if a string is a valid shuffle of two strings
  168. Java Program to Implement the graph data structure