Java programs

Let’s learn java program to add two numbers using bufferedreader. Java program to add two numbers using bufferedreader In the below program to add two numbers using bufferedreader first get input from user using readLine() method of BufferedReader class. In the next step convert string to integer using Integer.parseInt() method. This method returns the integer…

Read More Java program to add two numbers using bufferedreader

Let’s learn string palindrome in java using stringbuffer. String palindrome in java using stringbuffer Let’s learn to check if a string is a palindrome using StringBuffer. First we have to create StringBuffer object ‘sb’. Then pass given string as parameter to the constructor. Now reverse contents of given string using reverse() method of StringBuffer class.…

Read More String palindrome in java using stringbuffer

Let’s learn how to check if a string is in alphabetical order in java. How to check if a string is in alphabetical order in java To check if a string is in alphabetical order or not first store the given string in String variable “strInput”. Before going to next step first create static checkIfAlphabaticOrder(String…

Read More How to check if a string is in alphabetical order in java

Let’s learn to arrange words of a sentence in alphabetical order in java. Arrange words of a sentence in alphabetical order in java In the below example we are using collection to arrange words of a sentence in alphabetical order. Here’s the program to arrange words of a sentence in alphabetical order in java. import…

Read More Arrange words of a sentence in alphabetical order in java

Let’s learn java program to find largest of four numbers using nested if. Java program to find largest of four numbers using nested if In below java program first user is asked to enter four numbers one by one using nextInt() method of Scanner class. These four numbers are stored in four integer variables number1,…

Read More Java program to find largest of four numbers using nested if

Let’s learn java program to find smallest of three numbers using ternary operator. Java program to find smallest of three numbers using ternary operator In the below program we are using two ternary operators to find the smallest of three numbers. Ternary operator in java comprises of a condition which evaluates to either true or…

Read More Java program to find smallest of three numbers using ternary operator

Let’s learn java program to remove consonants from a string. Java program to remove consonants from a string Here’s the program to remove consonants from a string. For example, Input string: hello world core java Output string: eo o oe aa Input string: flower brackets Output string: oe ae import java.util.Arrays; import java.util.List; public class…

Read More Java program to remove consonants from a string