File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Error while compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error while compiling " Watch "Error while compiling " New topic

Error while compiling

mahesh amber

Joined: Mar 11, 2008
Posts: 7
why i my getting the error while compiling the java program

here what is unchecked and unsafe operations and when i compile with -Xlint it gives a series of warning that no where related to my program
thanks in advance
abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
Hi mahesh
what you are getting is not a error its a warning, which means you can still execute your code....
you are getting this warning because you are using non-generic collections in your code... Generics is a feature newly added to Java 5 which basically makes your collections type safe meaning you can restrict the type of objects your collection can hold....
for eg in Java 5 you would declare a List as
List<String> list = new ArrayList<String>();
the above declaration will construct a list which will hold only Strings ,trying to add anything other than String will result in a compile error the <String> is the Generic syntax
Similarry you can also make a List as
List<MyClass> list = new ArrayList<MyClass>();
which will hold only objects of MyClass
this basically gives you type safety ( hence the warning unsafe unchecked operations because non-generic collections are not type safe meaning you can any object in them )
If you are new to Java 5 or new to Generics maybe you should spend some time getting familar with it
[ March 21, 2008: Message edited by: abhishek pendkay ]

The significant problems we face cannot be solved by the same level of thinking which created them – Einstein
SCJP 1.5, SCWCD, SCBCD in the making
mahesh amber

Joined: Mar 11, 2008
Posts: 7
thanks for the reply
but iam able to execute the code if i compile with Xlint then i get some warnings
wood burning stoves
subject: Error while compiling
It's not a secret anymore!