| 
 | 
Mike Wills wrote:
> I get this error message: "non-static method
> sortArrayAsc(java.lang.String[]) cannot be referenced
> from a static context". What does this mean exactly?
Dear Mr. Wills:
It means it's an instance method, and you're trying to call it as if it
were a class method.
Consider the class Foo (and please ignore any syntax errors; I don't
usually code Java at home):
Class Foo extends Baz implements Bar {
    static int fizmo(int frotz) {
        int dimwit = frobozz(frotz + 3);  /* won't compile */
        Foo anInstance = new Foo();
        int flathead = anInstance.frobozz(frotz); /* compiles and runs
fine */
        int zork = prosser(5 * frotz);   /* and so does this */
        return zork + flathead * dimwit;
    }
    int frobozz (int mumbar) {
         return prosser(5 * mumbar); /* and so does this */
    }
    static int prosser (int zifmia) {
         return zifmia - 2;
    }
}
The line marked "won't compile" will give you the same error you're
describing, because it's calling an instance method without an instance.
--
James H. H. Lampert
Professional Dilettante
http://www.hb.quik.com/jamesl
http://members.hostedscripts.com/antispam.html
http://www.thehungersite.com
Read My Lips: No More Atrocities!
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.