Basic JAVA Programs

BASIC JAVA PROGRAMS

Before you start with JAVA programming, if you have just begun to program in JAVA(beginner), then do not directly go for the programs, before that just view this link on different ways of accepting input in JAVA, else go straight to the programs.

 

JAVA program to add two numbers
JAVA program to use bitwise operators like &(AND), |(OR), <<(LEFT SHIFT), >>(RIGHT SHIFT) , ~(NEGATION)
JAVA program to find the maximum between three numbers(show how to use if else statement)
JAVA program to find the maximum between three numbers using ternary operator(conditional operator)
JAVA program to check if the given year is a leap year or not
JAVA program to check if the given number is even or odd
JAVA program to find odd numbers of first n terms
JAVA program to find sum of first n natural numbers
JAVA program to convert a decimal number to a binary number 
JAVA program to find factorial of a given number
JAVA program to check whether a given number is prime or not
JAVA program to generate prime numbers upto n
JAVA program to generate first n prime numbers
JAVA program to check whether the given number is an armstrong number or not
JAVA program to generate armstrong numbers from 1 to n 
JAVA program to generate first n armstrong numbers
JAVA program to find fibonacci series for first n terms
JAVA program to find fibonacci series upto n(upto a given range)
JAVA program to convert temperature from Fahrenheit to Celsius
JAVA program to reverse a number
JAVA program to check whether the given number is a palindrome or not
JAVA program to swap two numbers
JAVA program to swap two numbers without using a third variable or using only two variables
JAVA program to find lcm of two numbers
JAVA program to find gcd/hcf of two numbers
JAVA program to find lcm and gcd/hcf of two numbers
JAVA program to find the power of a number without using pow() method
JAVA program to find the power of a number using pow() method

JAVA program to generate random numbers(using the Random class)

Menu driven JAVA program for calculator (how to use switch case statement)
JAVA program to convert a string from lowercase to uppercase
JAVA program to convert a string from uppercase to lowercase
JAVA program to toggle all characters of a string
JAVA program to check if the string is a palindrome
JAVA program to find length of a string without using string method length()
JAVA program to find length of a string using string method length()
JAVA program to compare two strings without using string method equals()
JAVA program to compare two strings using string method equals()
JAVA program to reverse a string without using inbuilt method reverse()
JAVA program to reverse a string using reverse() method
JAVA program to concatenate two strings without using string method concat()
JAVA program to concatenate two strings using string method concat()
JAVA program to count number of vowels, consonants, digits,white spaces and special characters in a given string
Share Me!
  •  
  •  
  •  
  •  
  •  
  •