• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Java error  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to compile a java application and am getting an errror:


TestAccount.java:1: error: <identifier> expected
import.java.util.Scanner;
^
1 error

How do I fix this?


Original code:



Code:


import.java.util.Scanner;


public class TestAccount {
public static void main (String[] args) {
Scanner kb = new Scanner (System.in);

System.out.print("Enter the number for account #1: ");
int accountNo = kb.nextInt();

System.out.print("Enter the balance for account #1: ");
double balance = kb.nextDouble();

CheckingAccount account1 = new CheckingAccount(accountNo, balance);

System.out.print("Enter the number for account #2: ");
int accountNo = kb.nextInt();

System.out.print("Enter the balance for account #2: ");
double balance = kb.nextDouble();

CheckingAccount account2 = new CheckingAccount(accountNo, balance);

System.out.println("---ACCOUNT #1---");
System.out.println(account1);

System.out.println("---ACCOUNT #2---");
System.out.println(account2);
}
}



Thanks for any help.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello keith michael, welcome to the JavaRanch.

Could you edit your post and wrap your code with the code tags? It will help us to understand your code.

Is that your class code? is there any other line above the import?
 
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carefully look at the import statement. Some unwanted character lurking around there
 
Marshal
Posts: 60061
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The keyword import ought to be followed by a space, not a dot.

And welcome (again) I shall see about adding code tags for you since you are new, and you can see how much better the code looks.
 
Campbell Ritchie
Marshal
Posts: 60061
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code tags wouldn’t work because you haven’t indented the code you posted.
 
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!