Please put some more effort on your query, for sure you can come up with your answers by yourself and you will learn faster. For now You can refer to below answer.

package com.barnwal.jeetendra.learn;
import java.util.Scanner;

public class Assignment4 {

    public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    System.out.print("Enter the first integer:");
    int first = s.nextInt();
    System.out.print("Enter the second integer:");
    int second = s.nextInt();
    System.out.println("How many integers are between " + first + " and "
            + second + "???");

    // To print number of integer between entered number
    if (second > first) {
        System.out.println("Answer : " + (second - first - 1));

        // To print the numbers
        for (int i = first + 1; i < second; i++)
            System.out.print(i + " ");
    } else {
        // To print number of integer between entered number
        System.out.println("Answer : " + (first - second - 1));

        // To print the numbers
        for (int i = second + 1; i < first; i++)
            System.out.print(i + " ");
    }
 }
}
Answer from Jeetendra on Stack Overflow
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ Java-program-to-print-the-Armstrong-numbers-between-two-numbers
Java program to print the Armstrong numbers between two numbers
import java.util.Scanner; public class ArmstrongBetweenTwoNumbers { public static void main(String args[]){ int num1, num2; Scanner sc = new Scanner(System.in); System.out.println("Enter the first number ::"); num1 = sc.nextInt(); System.out.println("Enter the second number ::"); num2 = sc.nextInt(); for (int i = num1; i<num2; i++){ int check, rem, sum = 0; check = i; while(check != 0) { rem = check % 10; sum = sum + (rem * rem * rem); check = check / 10; } if(sum == i){ System.out.println(""+i+" is an Armstrong number."); } } } }
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 69790921 โ€บ how-can-i-print-numbers-between-two-numbers-that-i-enter
java - How can I print numbers between two numbers that I enter? - Stack Overflow
Also you need to only cycle through ... bigger = Math.max(first, second); for(int i = smaller+1 ; i < bigger ; i++){ System.out.print(i + " "); } The only odd scenario here is where you input two numbers which are adjacent, which ...
๐ŸŒ
CodingTechRoom
codingtechroom.com โ€บ question โ€บ -java-print-integers-between-numbers
How to Write a Java Statement to Display Integers Between Two Given Numbers? - CodingTechRoom
Displaying all integers between two numbers in Java can be achieved using a simple loop. This process involves taking two input values and then iterating from the smaller to the larger value, printing each integer in between.
Top answer
1 of 5
2

Please put some more effort on your query, for sure you can come up with your answers by yourself and you will learn faster. For now You can refer to below answer.

package com.barnwal.jeetendra.learn;
import java.util.Scanner;

public class Assignment4 {

    public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    System.out.print("Enter the first integer:");
    int first = s.nextInt();
    System.out.print("Enter the second integer:");
    int second = s.nextInt();
    System.out.println("How many integers are between " + first + " and "
            + second + "???");

    // To print number of integer between entered number
    if (second > first) {
        System.out.println("Answer : " + (second - first - 1));

        // To print the numbers
        for (int i = first + 1; i < second; i++)
            System.out.print(i + " ");
    } else {
        // To print number of integer between entered number
        System.out.println("Answer : " + (first - second - 1));

        // To print the numbers
        for (int i = second + 1; i < first; i++)
            System.out.print(i + " ");
    }
 }
}
2 of 5
2

To avoid the unnecessary if-else statement to look which value is bigger, you can also use the functionality of the class java.lang.Math like this

Scanner s = new Scanner(System.in);
System.out.print("Enter the first integer:");
int first = s.nextInt();

System.out.print("Enter the second integer:");
int second = s.nextInt();

int small = Math.min(first, second) ;
int big = Math.max(first, second);

System.out.println("How many integers are between " + small +  " and " + big + "???");
System.out.println("Answer : " + (big - small + 1));

// To print the numbers
for (int i = small; i <= big; i++)
    System.out.print(i + " ");
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ java_output_numbers.asp
Java Output Numbers / Print Numbers
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... You can also use the println() method to print numbers.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 39984311 โ€บ create-method-that-prints-the-numbers-between-two-specified-numbers
java - Create method that prints the numbers between two specified numbers - Stack Overflow
* This number would be the leftBoundery plus one * This number will be the starting point of your loop */ final int firstNumber = leftBoundary + 1; // final int firstNumber = leftBoundary; //if you want to include the left boundary for ( int currentNumber = firstNumber; //Set the counter of the the loop (currentNumber) to the first valid number currentNumber < rightBoundary; //Run the loop while the loop counter is less than the rightBoundary // currentNumber <= rightBoundary; //If you want to include the right boundary currentNumber++ //Increment the loop counter with each iteration ){ /** * In each iteration you will print the current value of the counter to the console * Because your counter (currentNumber) will be incremented from the first valid number * to the last number before the right boundary you will get all numbers between the two * boundaries.
๐ŸŒ
GitHub
gist.github.com โ€บ sanikamal โ€บ a8c69ccdd045b13d95d3fa5836631aff
Java program to list all the integers between two integers L and R (including L and R). L and R can be any integer between 1 and 100. 1โ‰คL,Rโ‰ค100
Java program to list all the integers between two integers L and R (including L and R). L and R can be any integer between 1 and 100. 1โ‰คL,Rโ‰ค100 - NumberInRange.java
Find elsewhere
๐ŸŒ
w3resource
w3resource.com โ€บ java-exercises โ€บ basic โ€บ java-basic-exercise-50.php
Java - Numbers between 1 to 100, divisible by 3, 5 and both
Write a Java program to print numbers between 1 and 100 divisible by 3, 5 and both. ... public class Exercise50 { public static void main(String args[]) { // Print numbers divided by 3 System.out.println("\nDivided by 3: "); for (int i = 1; i < 100; i++) { if (i % 3 == 0) System.out.print(i + ", "); } // Print numbers divided by 5 System.out.println("\n\nDivided by 5: "); for (int i = 1; i < 100; i++) { if (i % 5 == 0) System.out.print(i + ", "); } // Print numbers divided by both 3 and 5 System.out.println("\n\nDivided by 3 & 5: "); for (int i = 1; i < 100; i++) { if (i % 3 == 0 && i % 5 == 0) System.out.print(i + ", "); } System.out.println("\n"); } }
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Print Numbers Between Two Values in Java Without Including the First Value - YouTube
Discover how to print numbers between two integers in Java without including the starting number. Learn with clear examples and coding tips!---This video is ...
Published ย  August 24, 2025
Views ย  0
๐ŸŒ
Decode School
decodeschool.com โ€บ Java-Programming โ€บ Language-Basics โ€บ Java-Program-to-print-two-numbers-in-two-lines
Java Program to print two numbers in two lines | Java Programming | Decode School
import java.util.*; class Line ... Scanner(System.in); System.out.println("Enter The Two Inputs:"); Input1=sc.nextInt(); Input2=sc.nextInt(); System.out.println("The Outputs:"+Input1+"\n"+Input2); } }...
๐ŸŒ
OneCompiler
onecompiler.com โ€บ java โ€บ 3wkt7bwkr
Print numbers 1 to 10 each number in a separate line using java - Java - OneCompiler
OneCompiler's Java online editor supports stdin and users can give inputs to the programs using the STDIN textbox under the I/O tab. Using Scanner class in Java program, you can read the inputs.