• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java error  RSS feed

 
keith michael
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.
 
Hebert Coelho
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?
 
Mohamed Sanaulla
Bartender
Posts: 3184
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
 
Campbell Ritchie
Marshal
Posts: 56223
171
  • 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: 56223
171
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!