Search:

Type: Posts; User: Wice

Search: Search took 0.08 seconds.

  1. Re: Link objects and calling a variable object's method

    Thanks aliteralmind but I don't understand how that would allow me to do something like:

    arrObjects[2].doSomething();
  2. Re: Link objects and calling a variable object's method

    Well, I could have a Team object, inside it is an array with Player objects. There could be 3 players but there just as well could be 11 players. At some point I want to call a method from every...
  3. Re: Link objects and calling a variable object's method

    Well, I was working on something that could call a method of an object without calling a specific object by its name.
  4. Re: Link objects and calling a variable object's method

    I think I was thinking too much in a PHP way, I changed the array from a string type, to a TestThing type and got it working like this:


    public class Test {

    public static void main(String[]...
  5. Re: Link objects and calling a variable object's method

    arrObjectNames[0] = "objFirst";
    arrObjectNames[1] = "objSecond";
    arrObjectNames[2] = "objThird";

    TestThing objFirst = new TestThing();
    TestThing objSecond = new TestThing();...
  6. Re: Link objects and calling a variable object's method

    Whoops, my bad, sorry. It still doesn't work though



    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method doSomething() is undefined for the type String
    ...
  7. Re: Link objects and calling a variable object's method

    Alright, this is my very short example code:



    public class TestThing {

    public void doSomething(){
    System.out.println("succes");
    }
    }
  8. Re: Link objects and calling a variable object's method

    Sorry to ask this before trying but I'm not currently behind my computer:

    Say I make a new variable, call it targetBook and give it a value of "bookA"

    would targetBook.methodName(argsToMethod)...
  9. Re: Link objects and calling a variable object's method

    Thanks, my second question could be asked in a more simple way I guess: How can I call a method from an object based on a variable object name?
  10. Link objects and calling a variable object's method

    Hello,

    I've been searching quite a while for an answer but seeing as I could not find it, I decided to come here, hoping someone could help me.

    Say I have two classes, Author and Book, and I...
Results 1 to 10 of 10