• Post Reply Bookmark Topic Watch Topic
  • New Topic

identifier expected  RSS feed

 
Ishi Ann
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a BankAccount class.
My code currently looks like this:

import java.io.*;
import java.util.*;

public class BankAccount {

public status void main (String[] args); {

double balance;
int accountnumber;
int accounttype;
string ownername;
string password;
double interestrate;
boolean open;
int PIN;}

private void create (double start, int atype, string name, string pass, int P, dou\
ble rate, int accountnum); {

double balance = start;
int accountnumber = accountnum;
int accounttype = atype;
string ownername = name;
string password = pass;
double interestrate = rate;
int PIN = P;
boolean open = true;
}

double getBalance () {

Return balance;
}
}

The error that pops up is:

BankAccount.java:6: <identifier> expected
public status void main (String[] args); {
^
1 error

Any help is appreciated.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct signature for the main method is:

public static void main(String[] args)
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Offhand, I see two problems with this line...

First, "status" should be "static." And second, you should not have a semicolon between the parenthesis and the opening brace.
 
Ishi Ann
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, thanks, you guys!
I can't believe I overlooked that ><

Um...now I have 15 errors...

BankAccount.java:17: cannot find symbol
symbol : class string
location: class BankAccount
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {
^
BankAccount.java:17: cannot find symbol
symbol : class string
location: class BankAccount
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {
^
BankAccount.java:11: cannot find symbol
symbol : class string
location: class BankAccount
string ownername;
^
BankAccount.java:12: cannot find symbol
symbol : class string
location: class BankAccount
string password;
^
BankAccount.java:17: missing method body, or declare abstract
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {
^
BankAccount.java:19: cannot find symbol
symbol : variable start
location: class BankAccount
double balance = start;
^
BankAccount.java:20: cannot find symbol
symbol : variable accountnum
location: class BankAccount
int accountnumber = accountnum;
^
BankAccount.java:21: cannot find symbol
symbol : variable atype
location: class BankAccount
int accounttype = atype;
^
BankAccount.java:22: cannot find symbol
symbol : class string
location: class BankAccount
string ownername = name;
^
BankAccount.java:22: cannot find symbol
symbol : variable name
location: class BankAccount
string ownername = name;
^
BankAccount.java:23: cannot find symbol
symbol : class string
location: class BankAccount
string password = pass;
^
BankAccount.java:23: cannot find symbol
symbol : variable pass
location: class BankAccount
string password = pass;
^
BankAccount.java:24: cannot find symbol
symbol : variable rate
location: class BankAccount
double interestrate = rate;
^
BankAccount.java:25: cannot find symbol
symbol : variable P
location: class BankAccount
int PIN = P;
^
BankAccount.java:31: cannot find symbol
symbol : class Return
location: class BankAccount
Return balance;
^
15 errors

Advice?
 
Ishi Ann
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
***
Here's what I have now:

import java.io.*;
import java.util.*;

public class BankAccount {

public static void main (String[] args) {

double balance;
int accountnumber;
int accounttype;
String ownername;
String password;
double interestrate;
boolean open;
int PIN;}

private void create (double start, int atype, string name, string pass, int P, dou\
ble rate, int accountnum); {

double balance = start;
int accountnumber = accountnum;
int accounttype = atype;
String ownername = name;
String password = pass;
double interestrate = rate;
int PIN = P;
boolean open = true;
}

double getBalance () {

return balance;
}
}

11 Errors:

BankAccount.java:17: cannot find symbol
symbol : class string
location: class BankAccount
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {
^
BankAccount.java:17: cannot find symbol
symbol : class string
location: class BankAccount
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {
^
BankAccount.java:17: missing method body, or declare abstract
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {
^
BankAccount.java:19: cannot find symbol
symbol : variable start
location: class BankAccount
double balance = start;
^
BankAccount.java:20: cannot find symbol
symbol : variable accountnum
location: class BankAccount
int accountnumber = accountnum;
^
BankAccount.java:21: cannot find symbol
symbol : variable atype
location: class BankAccount
int accounttype = atype;
^
BankAccount.java:22: cannot find symbol
symbol : variable name
location: class BankAccount
String ownername = name;
^
BankAccount.java:23: cannot find symbol
symbol : variable pass
location: class BankAccount
String password = pass;
^
BankAccount.java:24: cannot find symbol
symbol : variable rate
location: class BankAccount
double interestrate = rate;
^
BankAccount.java:25: cannot find symbol
symbol : variable P
location: class BankAccount
int PIN = P;
^
BankAccount.java:31: cannot find symbol
symbol : variable balance
location: class BankAccount
return balance;
^
11 errors
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you have a lot of compiler errors, it is generally good to fix the first few, and then recompile. Later errors meesages are not that reliable because they may be caused by the earlier errors.

Anyway, your first error...

BankAccount.java:17: cannot find symbol
symbol : class string
location: class BankAccount
private void create (double start, int atype, string name, string pass, int P, double rate, int accountnum); {


Is caused by Java not being able to find the "string" class. Java is case sensitive, and I am assuming that you want the "String" class.

Henry
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What IDE are you using for development?
Any self respecting IDE nowadays will prompt you for errors even before you compile.
It is sort of the red markers you get on the UI when you make a spelling mistake.
Lot of developers, including myself, use Eclipse.
If you google for it, I am sure you will find many more.
It might be a good idea, to start using one of these. It is sure to save you lot of trouble down the line.

PS. I would strongly advise you against going in for the drag and drop kind of IDE tools. Hand coding is the best way of learning things.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ishi, please Use Code Tags in the future. That will preserve spaces and tabs and make your code a lot better readable.
[ September 18, 2008: Message edited by: Rob Prime ]
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However useful Eclipse is, Maneesh, most beginners are better off with a text editor. There is too much to learn, trying to learn programming and a sophisticated bit of software at the same time.

Don't use NotePad however, Ishi Ann; if you are on Windows get NotePad++ or NotePad2 which are completely different tools (I suspect they are actually related to each other), and can be configured with syntax colouring, automatic indentation, and highlighting of matching {} [] or (), which all help finding such little errors.

Another major error: you haven't got a constructor in your class.

And welcome to JavaRanch
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
However useful Eclipse is, Maneesh, most beginners are better off with a text editor.


Point taken.
I would like to add to Campbell's list.
TextPad and EditPlus are relative easy too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!