• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Error while compiling

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
mahesh
 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
mahesh amber
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply
but iam able to execute the code if i compile with Xlint then i get some warnings
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic