• 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

how to solve unchecked or unsafe operation

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i solve this problem Unchecked or unsafe operations error in java compile?
this my coding
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Adam, welcome to the Ranch!

When posting code it's recommended to UseCodeTags (<- click link) to make your code nice and easy to read. I added them for you this time, looks better already.

On what line of that code does the compiler say there's a problem?
 
adam harris
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you TIM.. sorry i'm newbie here.. actually used CMD to compiler. i didn't know what line the problem. actually i'm beginner in java. i have a problem to understand this coding.
 
Tim Cooke
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The compiler will tell you what line it is. Somewhere in the error message you'll get something like DataSample.java:45 which tells you that the error is on line 45. What number do you have in your error message?
 
adam harris
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


the original code before i repair.. the problem start line from 3, 7 and 11
 
Ranch Hand
Posts: 789
Python C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

adam harris wrote:
the problem start line from 3, 7 and 11


First thing I notice is line 3 won't compile. It should use 0.0F. Because 0.0 by itself is a double, which you can't assign to a float..
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are probably getting warnings because you are using raw types - those are generic types which you are using without specifying a type parameter.

You are for example using Vector, but you don't specify the type parameter. Instead of

you should have used:


If you're unfamiliar with generics, see Lesson: Generics in Oracle's Java Tutorials.

Another thing (which is not the cause of the compiler warnings): class Vector is a legacy collection class. You should use the newer class ArrayList instead of Vector.
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Another thing (which is not the cause of the compiler warnings): class Vector is a legacy collection class. You should use the newer class ArrayList instead of Vector.



I mentioned this a while ago, and somebody (Sorry, I forgot who) corrected me that Vector is still a viable option if you need a synchronized list. I've never needed it so far though.
 
adam harris
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you jesper. how can i create main class base on this code.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic