Shadab says:
When I compile the above class on Windows the command prompt says -
"Note: src\com\example\model\BeerExpert.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."
However the class is compiled.
Shadab - Later versions of Java will generate that error because, unlike previous versions, the Collection
classes now work with generics, and can enforce the object type that they contain. Your program builds
a List of Strings. Replace the line that creates the brands list with the following, and your warnings should
go away:
What this does is to declare that your new List will only accept String objects. A compile-time error
will be thrown if you try to put any other type of object in the list.