Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

array error -- incompatible types  RSS feed

 
Roxanne Billings
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am hoping someone can help me. I have two methods one that is of double type and the other of int type; I have to use the int type method to reverse the results of the double method. I am listing my code below with the hope that someone can point me in the right direction on how to call the int method properly.

 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to change the reverse methods parameter and return type to double. But if the assignment says that it needs to be an int[] then you need to create a new array and cast all the elements.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the JavaRanch.
 
Roxanne Billings
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for the help; I did try to make the reverse method a double and had another error--but let me try it again to see if I can make it work from your suggestion. I just found this forum today, it is really cool. I am an online student so these forums really help me especially since I am no "classroom" interaction.

RB
 
Roxanne Billings
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WOW!!! Thank you so, so much for your help!! IT WORKED!!!
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!