basgen
asked on
errors...
first add setters and getter to your class
public class Transaction {
private String recordTrans ;
private String accountNumber1 ;
private String accountNumber2 ;
private double amt ;
private Calendar date ;
private String type ;
Calendar date;
private Object rec;
public Transaction(){
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}
Transaction tx = new Transaction();
tx.setType("xxx");
tx.setDate(Calendar.getIns tance());
}
this is my file and I am getting errors...cld someone help to fix...i dont get what its saying.
these are the errors: --------------------Config uration: <Default>----------------- ---
C:\Documents and Settings\Transaction.java: 1: 'class' or 'interface' expected
first add setters and getter to your class
^
C:\Documents and Settings\Transaction.java: 2: <identifier> expected
^
C:\Documents and Settings\Transaction.java: 3: '{' expected
public class Transaction {
^
C:\Documents and Settings\Transaction.java: 33: <identifier> expected
tx.setType("xxx");
^
C:\Documents and Settings\Transaction.java: 34: <identifier> expected
tx.setDate(Calendar.getIns tance());
^
5 errors
Process completed.
for the setters and getters, my entry in is correct..but it still says an error...why?
public class Transaction {
private String recordTrans ;
private String accountNumber1 ;
private String accountNumber2 ;
private double amt ;
private Calendar date ;
private String type ;
Calendar date;
private Object rec;
public Transaction(){
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}
Transaction tx = new Transaction();
tx.setType("xxx");
tx.setDate(Calendar.getIns
}
this is my file and I am getting errors...cld someone help to fix...i dont get what its saying.
these are the errors: --------------------Config
C:\Documents and Settings\Transaction.java:
first add setters and getter to your class
^
C:\Documents and Settings\Transaction.java:
^
C:\Documents and Settings\Transaction.java:
public class Transaction {
^
C:\Documents and Settings\Transaction.java:
tx.setType("xxx");
^
C:\Documents and Settings\Transaction.java:
tx.setDate(Calendar.getIns
^
5 errors
Process completed.
for the setters and getters, my entry in is correct..but it still says an error...why?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Shoot I'll try.
ASKER
okie, i have this prob...this prog has so many errors and i cant understand where this is coming from? hava a look...ill give u the prog n the errors..
public class AuditedTest {
public static void main(String[] args) {
AuditedCard wallet[] = new AuditedCard [10]; ;
wallet[0] = new AuditedCard("5391 0375 9387 5309", "John Bowman",
"California Savings", 0.0, 2500);
wallet[1] = new AuditedCard("3485 0399 3395 1954", "John Bowman",
"California Federal", 0.0, 3500);
wallet[2] = new AuditedCard("6011 4902 3294 2994", "John Bowman",
"California Finance", 0.0, 5000);
System.out.println("Credit Card Payments:");
for(int j=0; j<wallet.length; j++) {
if(j==0){
wallet[j].recordTrans("new ", 0);
for (int i=1; i<=16; i++) {
wallet[j].recordTrans("deb it", (double) i);
}
wallet[j].print();
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].print();
} else if(j==1){
wallet[j].recordTrans("new ", 0);
for (int i=1; i<=16; i++) {
wallet[j].recordTrans("deb it", 2.0 * i);
}
System.out.println();
wallet[j].print();
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].print();
} else {
wallet[j].recordTrans("new ", 0);
for (int i=1; i<=16; i++) {
wallet[j].recordTrans("deb it", (double) 3 * i);
}
System.out.println();
wallet[j].print();
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre dit", 100.0);
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].print();
}
}
}
}
when i run the prog, i get an error, exception in thread "main" java .lang.NullpointerException at AuditedTest.main...would you be able to have a look?
public class AuditedTest {
public static void main(String[] args) {
AuditedCard wallet[] = new AuditedCard [10]; ;
wallet[0] = new AuditedCard("5391 0375 9387 5309", "John Bowman",
"California Savings", 0.0, 2500);
wallet[1] = new AuditedCard("3485 0399 3395 1954", "John Bowman",
"California Federal", 0.0, 3500);
wallet[2] = new AuditedCard("6011 4902 3294 2994", "John Bowman",
"California Finance", 0.0, 5000);
System.out.println("Credit
for(int j=0; j<wallet.length; j++) {
if(j==0){
wallet[j].recordTrans("new
for (int i=1; i<=16; i++) {
wallet[j].recordTrans("deb
}
wallet[j].print();
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].print();
} else if(j==1){
wallet[j].recordTrans("new
for (int i=1; i<=16; i++) {
wallet[j].recordTrans("deb
}
System.out.println();
wallet[j].print();
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].print();
} else {
wallet[j].recordTrans("new
for (int i=1; i<=16; i++) {
wallet[j].recordTrans("deb
}
System.out.println();
wallet[j].print();
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].recordTrans("cre
System.out.println("New Balance = " + wallet[j].getBalance());
wallet[j].print();
}
}
}
}
when i run the prog, i get an error, exception in thread "main" java .lang.NullpointerException
ASKER