• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic