Triplets program is showing error (JAVA)

why it is showing no output and wrong error but it is giving correct output while compiling
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
int tar=sc.nextInt();
int num1,num2,num3;
for(int j=0;j<n-2;j++)
{
for(int k=j+1;k<n-1;k++)
{
for(int p=k+1;p<n;p++)
{
if(a[j]+a[k]+a[p]==tar)
{
num1=a[j];
num2=a[k];
num3=a[p];
if(num1<num2 && num2<num3 && num3<num1)
System.out.println(a[j] + “, " + a[k]+”, " + "and " +a[p]);
if(num1>num2 && num2<num3 && num3<num1)
System.out.println(a[k] + “, " + a[p]+”, " + "and " +a[j]);
if(num1<num2 && num2>num3 && num3>num1)
System.out.println(a[j] + “, " + a[p]+”, " + "and " +a[k]);

		   }
	   }
   }

}

}

}

Hi Akshay,
I worked on your code and found a mistake:
The mistake you were doing:
You were overkilling the simple problem by comparing the values to be printed which were equal to a Target.
for getting sorted order,I sorted your Array and then printed it.


Thankyou if further doubt persists revert back here else mark it resolve.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.