Error while submitting in Finding upper and lower bound

while submitting it is showing no output… is my solution correct? And how will i add the condition for (-1 -1) ?
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];
   int i;
   for(i=0;i<n;i++)
   {
	   a[i]=sc.nextInt();
   }
   int t=sc.nextInt();
   for(i=0;i<t;i++)
   {
       int ser=sc.nextInt();
	   int findex=0;
	   for(int j=0;j<n;j++)
	   {		   
		   if(a[j] == ser)
		   {   
			System.out.print(j+ " ");			      
		   }
		   break;
	   }
     for(int k=n-1;k>0;k--)
	 {
		 if(a[k]== ser)
		 {
			 System.out.print(k+ " ");
		 }
		 break;
	 }
	
   }
}

}

@akshay9009
Yes your logic is correct and in this question it is mandatory to add condition (-1 -1) when an element is not found in the array.

okay…i wanted to knw how can i add the (-1 -1 ) condition? by creating a new loop or just insert the if statement somewhere in the loops which are printing the values of indexes.
Thanks

Hi Akshay
you can add -1 -1 when the elements is not found after traversing/searching in the complete array.

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.