import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Scanner;
import javax.swing.text.html.HTMLDocument.Iterator;
class main{
public static int readinput () throws IOException
{
int n1=0;
int name=0;
System.out.println("Enter num");
@SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
try
{
name= in.nextInt();
return name;
}
catch(InputMismatchException e)
{
in.next();
System.out.print("error");
return 0;
}
}
@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
int num=0;
ArrayList<Integer> al = new ArrayList<Integer>();
while ((num!=42)&&(num<99))
{
{
num=readinput();
al.add(num);
}
if (al.size()>1)
{
al.remove(al.size()-1);
for (Integer integer : al) {
System.out.println(integer);
}
}
}
}
}
I am not sure why i am getting the NZEC error , in IED it works fine.