aspose file tools*
The moose likes Beginning Java and the fly likes Can't understand error...Please Help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic
Author

Can't understand error...Please Help?

Stevie McBride
Greenhorn

Joined: Feb 01, 2002
Posts: 5
When compiling the following code I keep getting the same error and I've tried changing a few things. I've not included the parameters in the error description but they do appear.
Error :- cannot resolve symbol!
CurrentAccountOne ca = new CurrentAccountOne("");
^
CurrentAccountOne ca = new CurrentAccountOne("");
^
Needless to say it's the same for sa & pa objects.
All files are in C:\jdk1.3\bin .
public class AccountDetailsOne
{
private String name ; // account holders name
private String accNum ; // account holders number

public String getName( )
{
return name ;
}
public String getAccNum( )
{
return accNum ;
}

public void setName( String s )
{
name = s ;
}
public void setAccNum( String n )
{
accNum = n ;
}

public AccountDetailsOne( ) { } // default constructor
public AccountDetailsOne( String s, String n, )
{
setName ( s ) ;
setAccNum ( n) ;
}

public void showDetails( )
{
System.out.println( " \tName : " + name ) ;
System.out.println( "\tAccNum : " + accNum ) ;
}
}
public class CurrentAccountOne extends AccountDetailsOne
{
private double balance ;
public int getBalance( )
{
return balance ;
}
public void setBalance( double b )
{
balance = b ;
}
public CurrentAccountOne( )
{
}
public CurrentAccountOne( String s , String n , double b )
{
super( s , n ) ;
setBalance ( b ) ;
}

public void showDetails( )
{
super.showDetails( ) ;
System.out.println( " \tBalance : � " + getBalance( ) ) ;
}
}
( The code for StudentAccountOne and PlatinumAccountOne is the same as Current)
public class BankAccountOne
{
public static void main( String [ ] args )
{
CurrentAccountOne ca = new CurrentAccountOne ( "Tony Zimmerman", "03454321", 500.00 ) ;
StudentAccountOne sa = new StudentAccountOne ( "Jackie Zimmerman " , " 09045321" , 750.00 ) ;
PlatinumAccountOne pa = new PlatinumAccountOne ( "Shuggy BalaB" , " 10992345" , 1500.00) ;
ca.showDetails( ) ;
System.out.println( ) ;
sa.showDetails( ) ;
System.out.println( ) ;
pa.showDetails( ) ;
System.out.println( ) ;
}
}
Stevie McBride
Greenhorn

Joined: Feb 01, 2002
Posts: 5
Sorry the second error should read
CurrentAccountOne ca = new CurrentAccountOne ("");
^ <--( pointer here!)
Thanks in advance for the help this is the best site in it's class. Stevie.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
What compiler version are you using?
The only thing that jumps out at me is that you don't have a constructor for CurrentAccountOne that takes a single String argument, so your instance creation expression:
CurrentAccountOne ca = new CurrentAccountOne("");
won't compile.
In my jdk 1.3 compiler I would expect to get an error message like:
"BankAccountOne.java": Error #: 300 : constructor CurrentAccountOne(java.lang.String) not found in class BankAccountOne at line 29, column 23

Maybe your compiler just gives you a different kind of message (can't resolve symbol).
But I would check on your object creation expression.

Rob


Rob
SCJP 1.4
Stevie McBride
Greenhorn

Joined: Feb 01, 2002
Posts: 5
Thanks Rob for the help. I have the same compiler as your good self but I've found that the code compiles when I type javac -classpath . BankAccountOne.java. The 3 parameters all show up in the error desription : I just left them out to save time. It would help if someone knew why it doesnt compile with just javac BankAccountOne.java . Thanks Again.
Kathy Rogers
Ranch Hand

Joined: Aug 04, 2000
Posts: 103
Hi Stevie,
This looks to me like a problem with your classpath setting. The classpath tells the compiler where to look for the classes you're using. I always put .; at the start of my classpath so that it looks for my classes in the current directory. If you want it to work without specifying the classpath at the commandline, you'll need to update your classpath environment variable - how you do that depends on your system but as I recall the java documentation you get when you download the SDK has some instructions for most platforms.
Hope this helps,
Kathy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't understand error...Please Help?