Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem while reading from console  RSS feed

 
Greenhorn
Posts: 24
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today I was trying to read input from console.I altered the code given in herbert shield's complete reference book but..but was getting error
"Type mismatch: cannot convert from int to String".

 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the input you are giving???
 
Sheriff
Posts: 21289
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're assigning the result of Integer.parseInt to String b, not int x. And please UseCodeTags next time.
 
Ranch Hand
Posts: 55
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also want to check this topic for more information: we-ask-user-input-writing
 
Sunni srivastav
Greenhorn
Posts: 24
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:You're assigning the result of Integer.parseInt to String b, not int x. And please UseCodeTags next time.



Thanks Rob.It worked now.
 
Rob Spoor
Sheriff
Posts: 21289
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!