Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Compile error in Java

  • 24-04-2011 8:13am
    #1
    Registered Users, Registered Users 2 Posts: 266 ✭✭


    Hi
    Can anybody help me with this error...

    java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    Tool completed successfully

    I'm trying to include a vector in a test program and I'm new to vectors.

    As I have searched elsewhere I am not sure if its a general error or if its specific to a certain piece of code.

    Any help appreciated.


Comments

  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    You know... that is the type of thing google can answer in a few seconds. It's a valuable tool you should use when learning.
    Look carefully at how vectors use generics!


  • Registered Users, Registered Users 2 Posts: 375 ✭✭unknownlegend


    croo wrote: »
    You know... that is the type of thing google can answer in a few seconds. It's a valuable tool you should use when learning.
    Look carefully at how vectors use generics!

    This! Stackoverflow has your answer, research generics in a bit more detail. Not being facetious at all but harnessing Google for problems such as this will greatly help you improve your skills.


  • Registered Users, Registered Users 2 Posts: 266 ✭✭Gerb68


    As I stated I have been googling and all I can find is that it may mean that I'm using a java 5 compiler to compile code that is written for java 4.

    I find when googling java issues it can be very difficult as results may include code that I have not yet covered. This can get confusing and can lead you away from the origional problem.

    I will continue to google, Thanx for the advice.


  • Registered Users, Registered Users 2 Posts: 375 ✭✭unknownlegend


    Can you check if that specific bit of code you're trying to compile has been.deprecated or similar?


  • Closed Accounts Posts: 5,482 ✭✭✭Kidchameleon


    I get this when I de-serialise an object, doesn't seem to cause any problems. My program runs fine...


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 266 ✭✭Gerb68


    (deleted)


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    Did you look at the topic of generics and how it's used in collections?
    Out of curiosity, did you follow the instructions and Recompile with -Xlint?

    This is just a warning so you should be able to run & test your code, but it is instructional to understand what the compiler is telling you!

    Instead of casting the BankAccounts to objects try defining the vector as:
    Vector<BankAccount> myBank = new Vector<BankAccount>(5);
    and just adding vector elements of type BankAccount!


Advertisement