java programs
- 18 January
Even odd program in java
In this post,we will see how to check if number is even odd. It is one of the basic programs of Java programming language. [crayon-6729d04674465539422773/] Output: Enter a Number : 22 22 is an Even Number That’s all about Even odd program in java.
- 18 January
Java Program to add two numbers
In this post, we will see how to add two numbers in java. This is the most basic program of java programming language. [crayon-6729d046746ef562318015/] Output: Enter two numbers : 5 7 Sum of two numbers is 12 If you notice, we have use Scanner to take input from user.
- 24 December
Reverse number in java
In this post, we will see how to reverse a number in java. Here is simple program to reverse a number. [crayon-6729d04674929464628217/] Output: Enter a Number : 4567 Reverse of the number : 7654 Let’s just observe values of variables at the end of each iteration. Iteration 0: number = 4567,remainder = 0, reversedNumber = […]
- 17 November
Java program to print floyd’s triangle
In this post, we will see how to print Floyd’s triangle in java. Problem You need to print Floyd’s triangle as below for n=5. Floyd’s triangle **************** 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Floyd’s triangle in java Let’s create class "FloydTriangleMainExample.java" as below [crayon-6729d046749d1172716120/] When you […]
- 27 October
Count number of words in a string
In this post, we will see how to find number of words in a String. Problem Find the number of words in a String. For example: There are 6 words in below String welcome to java tutorial on Java2blog Algorithm The algorithm will be very simple. Initialize count with 1 as if there are no […]
- 10 June
Java Interview Programs for Logic Building
In this tutorial, we will see Java interview programs for logic building. These java programs will help students to crack Java interview. Here is the list of Top 10 Java interview programs for logic building. Question 1: Check if number is odd or even? Answer: It is a very basic question. You need to check […]
- 20 January
How to check if number is power of two
In this tutorial, we will see how to check if number is power of two. There are many approaches to check if number is power of two or not. Approach 1: It is very easy and straight forward approach. Run a while loop which checks for condition if n is even number (n%2==0). If n is […]
- 24 September
Java Program to Find Second Largest Number in An Array
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. 1. Overview In this post, we will see how to find the second largest number in an array. This is a one of common interview questions on array data structure. 2. Introduction to Problem Statement Given […]
- 16 September
Java Program to Find Missing Number in An Array
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. 1. Overview In this article, we will see how to find missing number in Array of 1 to n. This is one of basic coding interview question asked in my interviews. 2. Introduction to Problem Statement […]