For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2006 > how to use static methods









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to use static methods
gencko

2006-03-22, 7:06 pm

i don't know whether this is the proper place to raise the following
question,if u think it's the wrong place to do so ,please delete this
post

i was told that within the static method , i can only use the static
methods or static variables,but i found that the following codes are
legal:
class abc
{...
public print()
{...}
}
class abc_ex
{ public static void main(string args[])
{ abc a=new abc();
...
a.print();
...
}
it seems that a.print() and new abc() are not static methods ,why??
thank you very much for your attention and help.

gencko

2006-03-23, 8:07 am

thanks a lot.

But i still got a little bit ,so can u give me an example to
show the wrong usage of statics?i mean what will the codes be like if
we tried to call instance methods in static context ,there are piles of
'good' codes and short passages about statics in the textbooks that i
read,so i really wanna what the 'bad' codes are like

thank you very much for another time

gencko

2006-03-24, 4:14 am

thanks ,i think i've got clear about this problem,really thanks a lot

gencko

2006-03-24, 4:14 am

thanks ,i think i've got clear about this problem,really thanks a lot

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com