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

Conflicting Variable Types???  RSS feed

 
Kenneth Kim
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following bit of code in one of my programs:




The compiler keeps returning an error message of incompatible types, saying that it's expecting a double type, and that its declared as a String??? Does the JOptionPane class only accept Strings? I'm so confused. Thanks for your help in advance!
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You delcared coa as double but the showInputDialog gets a string from the user.

Replace

with

Then it should compile without error.
[ September 17, 2005: Message edited by: KJ Reddy ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!