```
package maxmin;
import javax.swing.JOptionPane;
public class MaxMin
{
public static void main(String[] args)
{
final int Tnum = 5;
int num[] = new int[Tnum];
for(int i=0; i<num.length; i++)
{
String numstring = JOptionPane.showInputDialog(null,"Please enter number: ","User Input",
JOptionPane.QUESTION_MESSAGE);
num[i] = Integer.parseInt(numstring);
}
int max = num[0];
for(int i=0; i<num.length; i++)
{
if(max<num[i]);
max = num[i];
}
int min = num[0];
for(int i=0; i<num.length; i++)
{
if (min>num[i]);
min = num[i];
}
String MaxMin = "The array are : ";
for(int i=0; i<num.length; i++)
{
MaxMin = MaxMin + num[i] + " ";
}
MaxMin = MaxMin + "\nThe largest number is "+max;
MaxMin = MaxMin + "\nThe smallest number is "+min;
JOptionPane.showMessageDialog(null,MaxMin,"Number",
JOptionPane.INFORMATION_MESSAGE);
}
}
```

0

*Edited
by Dani*: Code formatting