By Editorial Staff. Updated on
In this program, we are going to share a Java program to print next greater elements in a given array. If you are a Java beginner and want to start learning the Java programming, then keep your close attention in this tutorial as I am going to share how to write a Java program to print next greater elements in a given array.
To increase your Java knowledge, practice all Java programs, here is a Collection of 100+ Java problems with solutions.
Copy the below Java program and execute it with the help of Javac compiler. At the end of this program, We have shared the output of this program.
class Main 11 — 13 Same programs in other languages:
static void printNGE(int arr, int n)
int next, i, j;
for (i=0; i
13 — 21
21 — -1
3 — -1
11 — 13
Same programs in other languages:
Sharing is caring!