• Post Reply Bookmark Topic Watch Topic
  • New Topic

Having trouble with a float ArrayList  RSS feed

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used ArrayLists successfully before and have even used them in a manner similar to what I'm trying to do with this class. I'm not sure why I'm getting the error messages.

Please help



Will someone please help me understand these errors
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using floats in the first place? Use doubles or BigDecimal.

You can only create a List of reference types. Double is a reference type and double[] is a reference type but double isn't. Simplest to create a List<Double> and use doubles and they will be boxed and unboxed as required.
 
Paul Peterson
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using float because that is part of the instruction for the project
 
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at this link >> TellTheDetails
Do you have anything else you didn't mention us as a part of project requirements?
 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not use primitives with collections. Use ArrayList<Float>.
 
Paul Peterson
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:Please have a look at this link >> TellTheDetails
Do you have anything else you didn't mention us as a part of project requirements?


nothing else that relates to this problem. I still have a few other issues in parts of the project, but they are not related to this.
 
Paul Peterson
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:You can not use primitives with collections. Use ArrayList<Float>.


That solved it, thank you!
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Peterson wrote:Using float because that is part of the instruction for the project
You reach a stage where you should start querying the instructions. Why do people insist on using floats?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!