Respuesta :
Answer:
Following are the code to this question:
import java.util.*;//import package
public class Main //defining a Main class Â
{
  public static void main(String[] args)//defining a main method Â
  {
    Scanner oxc = new Scanner(System.in);//defining main method Â
    int n,m1,m2,num,t,i;//defining integer variable
    n= oxc.nextInt();//input value from user end Â
    m1 = oxc.nextInt(); //input value from user end
    m2 = oxc.nextInt(); //input value from user end
    if (m1 > m2)//defining if block that check m1 greater then m2 Â
    {
      //swapping the value
      t= m1;
      m1 = m2;
      m2 = t;
    }
    for (i=2;i<n;i++)//defining for loop that check the smallest value  Â
    {
      num = oxc.nextInt();//input value from user end
      if (num < m1) //defining if block that check num lessthan m1
      {
        m2 = m1;//store m1 value into m2 Â
        m1 = num;//store num value into m1
      }
      else if (num<m2)//defining else if block that check num lessthan m2
      {
        m2 = num;//store m2 value in num
      }
    }
    System.out.println(m1 + " " + m2);//print value
  }
}
Output:
5
10
5
3
21
2
2 3
Explanation:
In the above-given code, inside the main class the main method is declared, in method 6 integer variable "n,m1,m2, num,t, and i" is declared, and in the "n, m1, m2, and num" is used for input the value from the user end.
- In the next step, and if block is defined that check m1 greater than m2, and swap the value.
- In the next step for loop s used that defines two conditions that check the two smallest value from the user input and print its value.