Here comes my code in java :
import java.util.Scanner;
public class repetedstring 
{
    public static void main(String[] args) 
    {
      int n = 0;
      Scanner a=new Scanner(System.in);
      System.out.println("Enter the value of n:");
      n=a.nextInt();
      String s[]=new String[n];
      for (int i = 0; i <n; i++) 
      {
          s[i]=a.nextLine();    
      }
      for (int i = 0; i<n-1 ; i++) 
      {
          if(s[i]==s[i+1])
          {
              System.out.println(s[i]);
          }
          else
          {
              System.out.println("not");
          }     
    }
}
}
If I give the value for n as 5 only 4 inputs are got by the compiler and the else part is only working. Please provide me some solution.
 
     
    