• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Coding  RSS feed

 
Vidush Bhardwaj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following program is written by me. By comparing the program given online, i found no errors. But still when i run this program in command window , it gives error. Hope you will help me with this . Thanks.


 
Tim Cooke
Marshal
Posts: 3873
233
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, welcome to the Ranch!

You don't say what the error is? Can you give some more information on that?
 
S Ry
Greenhorn
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tested your code in Eclipse and got output. There was no error.

output from your code

 
Campbell Ritchie
Marshal
Posts: 55768
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

Please show how you imported Scanner.
 
Paweł Baczyński
Bartender
Posts: 2054
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Ry, did the Eclipse do the auto-import thing?

The code, as posted by OP won't compile as the compiler wouldn't know what Scanner is.
 
Vidush Bhardwaj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is marked at the Scanner part...do we have to add anything for the compiler to be aware with the Scanner term??
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to add a line:

at the top of your source file.
 
Liutauras Vilda
Marshal
Posts: 4657
319
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from mentioned issue, there are still many issues left in your code. Have a look how the code formatting and indentation should be looking like. I also did some other amendments (added comments)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!