2 Replies Latest reply on Mar 19, 2007 3:23 PM by 800306

    cannot make a static reference

    807606
      What does this mean?

      Cannot make a static reference to the non-static method addLoan(Loans) from the type LoansRecords
        • 1. Re: cannot make a static reference
          807606
          public class X {
              private String s;
          
              public String getS() {
                  return s;
              }
          
              public static void main(String[] args) {
                  String result1 = getS(); //wrong -- what X object is being sent the message getS?
          
                  X x = new X();
                  String result2 = x.getS(); //right -- the message is being sent to x.
              }
          }
          • 2. Re: cannot make a static reference
            800306
            What does this mean?

            Cannot make a static reference to the non-static
            method addLoan(Loans) from the type LoansRecords
            It means your addLoan method is not static and you're trying to access it from something that is static. You should create a new instance of the method inside the static method so that it is referenced to something.

            EDIT: Too slow, and too wordy as well.

            Message was edited by:
            Djaunl