In the following code, there is no need for a wrapper term like '< String >' for the ArrayList ('ArrayList< String >'). The code executes just fine. I've seen it work with a wrapper and without a wrapper. I would understand if one creates his/her own class and there is a need to use it (i.e. '< Employee >'), but otherwise I am not seeing the point. Why is there an emphasis on using a wrapper term?
import java.util.*;
import java.io.*;
//import java.lang.*;
class Main {
public static void main(String[] args) throws Exception {
ArrayList obj3 = new ArrayList();
File obj = new File("c-keywords.txt");
BufferedReader obj2 = new BufferedReader(new FileReader(obj));
try{
String st;
while((st = obj2.readLine()) != null)
{
System.out.println(st);
}
for(int i = 0; i < obj3.size(); i++)
{
System.out.println(obj3.get(i));
}
}
catch(Exception e)
{
System.out.println("error");
}
}
}
Expected output:
Some kind of error
Actual output:
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while