zizi21
asked on
TestCAccount.java:13: non-static method print(CAccount) cannot be referenced from a static context
Hi,
I get the error below:
TestCAccount.java:13: non-static method print(CAccount) cannot be referenced from a static context
print(cDad);
^
I get the error below:
TestCAccount.java:13: non-static method print(CAccount) cannot be referenced from a static context
print(cDad);
^
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
well you could make the print method static, then you wouldn't get that error, but then if the print method itself makes references to non-static methods you'll get the same error in the print method and have to create an instance there...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
let me try it..i am a bit confused here..here..thanks
ASKER
sorry..just finished two other exams..going back to java..forgive me for the late reply...
You should typically be avoiding making things static.
You main should be creating an instance of a class (or classes) and calling (non-static) methods on those instances.
You main should be creating an instance of a class (or classes) and calling (non-static) methods on those instances.
ASKER
thanks!
ASKER