Re: Initiating a class



On Thu, 28 Jun 2007 08:29:33 -0700, christopher_board@xxxxxxxxxxx
wrote, quoted or indirectly quoted someone who said :

I am trying to write a program that has a separate class file to the
rest of the functions within the program. How would I go about making
a section of the program run what it is inside the class.

Any help in this matter would be appreciated

If you want to run a static method x inside class X you would write
X.x()

If you want to run an instance method inside class X, you first must
instantiate an object of type X with the constructor.

X myobject = new X();

Then you can invoke the method on it:

myobject.x();

see http://mindprod.com/jgloss/constructor.html
http://mindprod.com/jgloss/static.html
http://mindprod.com/jgloss/instance.html
http://mindprod.com/jgloss/method.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



Relevant Pages

  • Re: class trouble in one project
    ... You are trying to invoke an instance method as if it were static. ... Java has methods, but no functions. ... Don't bother with StrictMath unless you know ...
    (comp.lang.java.programmer)
  • Re: Want form to show changing data. But it could be closed, or closing, during update.
    ... instance method, except of course you need to explicitly specify the ... need a reference to the form somewhere...... ... Invoke a delegate on the form, the form will still be there. ... Pete, the data is coming through a socket connection, and who knows ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: mysterious overriding behavior
    ... a similar signature that exists only in Y. ... I can see that I am not overriding since the signatures are different. ... What I don't see, however, is why xy.speakwould not invoke ... "...when the virtual machine invokes an instance method, ...
    (comp.lang.java.programmer)
  • Re: Recursion in Ruby
    ... couldn't call a instance method. ... nil has a lot of methods you can invoke ... Java-stuff when I replied. ... A child of five could understand this! ...
    (comp.lang.ruby)