This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Scanner class import issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Scanner class import issue" Watch "Scanner class import issue" New topic
Author

Scanner class import issue

Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
I am working on a class assignment (not a java class... well it is a class on java, but not the meaning java has for class) and I am trying to get my program to allow user input from the command prompt. The problem is I keep getting errors about the import syntax saying that nothing is in the right place.




The program goes on, but I feel it is not important for the issue at hand. I appreciate any help on the matter
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9995
    
    7

Move line #5 (import statement) to line# 1 (before public class HultinBenProg4)


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
Thanks a lot, no more errors, program compiles fine
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36592
    
  16
Are you taking classes in Java, or classes about Java classes, or Java classes about classes?

More seriously, although the Sun style guide is 10 years old, the order of parts of a class is still accurate. You may omit parts of the order; for example it mentions public fields, but as a design principle most classes only have private fields, so you simply ignore that part. Also in class exercises about classes in class ( ) you may not have time to write all your documentation comments.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Scanner class import issue
 
Similar Threads
Identifier expected
Weird multiple output issue with if statements
Scanners, Strings and doubles... Help!
Adding a new array element is not saving to memory
method construction trouble