Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Compile error in Java

  • 24-04-2011 08: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,338 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: 356 ✭✭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: 356 ✭✭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,338 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