• 10 October

    Java program to print table of number

    In this post we will see how to print table of number in java. It is good program to practice for loop in java. [crayon-61e7e5d8dc25b414892189/] Output: Enter a Number : 8 Table of 8 is 8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 […]

  • 09 October

    Java program to calculate grade of students

    In this post, we will see how to calculate grade of students in java. Student’s grade is decided by average of marks.It is good program to practice execution of if statements in java. Here is simple program to calculate grade of students [crayon-61e7e5d8dd5d1216826038/] Output: Enter Marks for 5 Subjects : 50 60 70 80 90 […]

  • 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-61e7e5d8defe1164707634/] 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-61e7e5d8dfe98124040355/] When you […]

  • 27 October

    Java program to count number of words in a string

    In this post, we will see Java program 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 […]

  • 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 […]

  • 08 August

    Fibonacci series program in java

    If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. Fibonacci series is numerical series in which next number is sum of previous two numbers. For example : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. There are two ways to print Fibonacci […]

  • 01 August

    Java program to check Armstrong number

    Armstrong number is a 3 digit number which is equal to sum of cube of its digits. For example: 371,153 In this post,  we will see how to check for Armstrong number in java. [crayon-61e7e5d8e3698343465073/] When you run above program, you will get following output. [crayon-61e7e5d8e36a3366161810/] Please go through Frequently asked java interview Programs for more such […]

  • 01 August

    How to swap two numbers without using temporary variables in java

    In this post, we will see how to swap two numbers without using temporary variables. There are three ways to do it. Java program: [crayon-61e7e5d8e4677500197150/] When you run above program, you will get following output: [crayon-61e7e5d8e4683825454794/] Third way is fastest of all. Please go through Interview programs in java  for more such programs.