Results 1 to 2 of 2
  1. #1
    Manny123 is offline Member
    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0

    Exclamation Calling a method from another class help

    Java Code:
    public class Transaction
    {
        // instance variables - replace the example below with your own
        private Integer amount;
        private Integer balance;
    
        /**
         * Constructor for objects of class Transaction
         */
        public Transaction(Integer AccountNumber, Integer SortCode)
        {
        // initialise instance variables
           [B] if((AccountNumber != Account.getAccountNumber())&&(SortCode != Account.getSortCode())){[/B]
            System.out.print("Incorrect account number or sort code");
        }
        balance = null;
        amount = null;
        }
    I'm trying to do a check so that if the account number number and sort code (which they entered in the Account class) doesn't match what they have entered in the transaction class, it will display an error message however, i get an error on the line which is in bold stating (line 13) "non-static method getAccountNumber() cannot be referenced from a static context"

    What does that mean? :s

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Replies: 8
    Last Post: 04-18-2012, 04:58 PM
  2. How to know which class is calling a method?
    By ranju4u6 in forum New To Java
    Replies: 14
    Last Post: 09-16-2010, 08:41 AM
  3. Child-Class Calling a Method in a Parent-Class
    By Blah_ in forum New To Java
    Replies: 5
    Last Post: 09-29-2009, 02:48 AM
  4. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  5. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 12:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •