Java Packages
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   P_T
Posted On:   Tuesday, June 19, 2001 10:40 AM

I am getting the following error message when I try to run the following program, though it seems to compile fine. package MyPack; class Balance { String name; double bal; Balance(String n, double b) { name = n; bal = b; } void show() { if(bal <0) System.out.print("-->>"); System.out.println(name + ": $" + bal); } } class AccountBalance { public static void main(String args[]) { Balance current[] = new Balance[3]; current[0] = new Balance("K.J.Fielding", 123.23); current[1] = new Balance("Will Tell", 157.02); current[2] =    More>>

I am getting the following error message when I try to run the following program, though it seems to compile fine.


package MyPack;

class Balance {
String name;
double bal;

Balance(String n, double b) {
name = n;
bal = b;
}

void show() {
if(bal <0)
System.out.print("-->>");
System.out.println(name + ": $" + bal);
}
}

class AccountBalance {
public static void main(String args[]) {
Balance current[] = new Balance[3];

current[0] = new Balance("K.J.Fielding", 123.23);
current[1] = new Balance("Will Tell", 157.02);
current[2] = new Balance("Tom Jackson", -12.33);

for(int i=0; i <3; i++) current[i].show();
}
}


My working directory is C:jdk1.3.1libclasses. I have created a subdirectory called MyPack under classes.

Please advise.

Regards,

   <<Less
About | Sitemap | Contact