Java2Blog
  • Home
  • Core Java
  • Tutorials
    • Spring
    • Spring Boot
    • Spring MVC
    • Java 8
    • Hibernate
  • Categories
    • Interview Questions
    • Spring Frameworks
    • Core java
    • Python
    • C++
  • NM
close
import_contacts

Java Tutorials

  • Core Java
  • Java Interview questions
  • Java 8 Stream
  • Java interview programs
import_contacts

Data structure and algorithm

  • Data structure in java
  • Data structure interview questions
import_contacts

Spring tutorials

  • Spring tutorial
  • Spring boot tutorial
  • Spring MVC tutorial
  • Spring interview questions

Basic java programs

  • Basic java programs
    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-683aa06e8703e540417000/] When you […]

    Read More
  • Basic java programs Core Java interview String
    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 […]

    Read More
  • Basic java programs Number
    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 […]

    Read More
  • Basic java programs Number
    15 December

    How to find GCD and LCM of two numbers in java

    In this post, we will see how to find Greatest common divisor(GCD) and Least Common Multiple(LCM) in java. GCD is calculated using Euclidean algorithm and LCM is calculated using reduction by GCD Eucid algo for calculating GCD is: Lets say , there are two numbers , a and b so GCD of two numbers = […]

    Read More
  • Basic java programs Core Java interview Number
    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-683aa06e884f8392610416/] When you run above program, you will get following output. [crayon-683aa06e884fd077793918/] Please go through Frequently asked java interview Programs for more such […]

    Read More
  • Algorithm Interview Basic java programs String
    01 August

    Java program to reverse a String

    In this post,  we will see java program to reverse a String. There are many ways to do reverse a String in java, some of them are: Using for loop Declare empty String reverse. This will contain our final reversed string. Iterate over array using for loop from last index to 0th index Add character […]

    Read More
  • Basic java programs Number
    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-683aa06e88745254192440/] When you run above program, you will get following output: [crayon-683aa06e88748352138500/] Third way is fastest of all. Please go through Interview programs in java  for more such programs.

    Read More
  • Basic java programs Number
    10 July

    How to find prime factors of a number in java

    In this post, we will see how to find prime factors of a number in java. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The prime factors of a number are all of the prime numbers that will exactly divide the given number. […]

    Read More
  • Basic java programs Core Java interview Number
    09 July

    java program to check prime number

    This is easy question. It may not be asked you directly, but you can use this program to create many other complex program. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Program logic: If any number which is not divisible by any other […]

    Read More
  • keyboard_arrow_left Previous
  • 1
  • …
  • 3
  • 4
  • 5
  • 6
  • Nextkeyboard_arrow_right

Newsletter


Let’s be Friends

  • Facebook
  • Twitter
  • LinkedIn

© 2020-22 Java2Blog Privacy Policy