About 256,000 results
Open links in new tab
  1. Calling methods in Java - Stack Overflow

    This is hard to get at first but there is a difference between the concept of object and class in object oriented programming and therefore in Java. Note also that when you call a static method, you use the name of the class containing the static method because the static method is a concept defined for the class not the particular objects ...

  2. reflection - How do I invoke a Java method when given the …

    public or non-public method call (for the latter,you need to call setAccessible on the method within an doPrivileged block, other findbugs won't be happy) encapsulating into one more manageable applicative exception if you want to throw back the numerous java system exceptions (hence the CCException in the code below)

  3. java - Calling a method inside another method in same class

    May 4, 2014 · The add method that takes a String and a Person is calling a different add method that takes a Position.The one that takes Position is inherited from the ArrayList class.

  4. java - How to call the overridden method of a superclass ... - Stack ...

    Don't pass child class reference to super class and except super class method has to be invoked for overridden method. Call super class methods from super class instance. Animal myAnimal = new Animal(); myAnimal.eat(); If you want to call super class method from child class, explicitly call super class method name with super.methodName();

  5. Java Inheritance - calling superclass method - Stack Overflow

    As a Java beginner I just wonder why super() does not have the magic to know in which method it is being used (Meaning: If foo() calls super(), it's obvious that super() means super.foo(). Constructors are just too special in Java IMHO) See Precursor in Eiffel, where it's done right. –

  6. How to call a method in another class in Java? - Stack Overflow

    Jul 11, 2013 · Currently I have two classes. a classroom class and a School class. I would like to write a method in the School class to call public void setTeacherName(String newTeacherName) from the classroom c...

  7. Using "this" with methods (in Java) - Stack Overflow

    May 11, 2015 · EDIT: I can't think of any examples why you'd want it for a straight this.foo() method call. EDIT: saua contributed this on the matter of obscure inner class examples: I think the obscure case is: OuterClass.this.foo() when accessing foo() of the outer class from the code in an Inner class that has a foo() method as well.

  8. How to pass a function as a parameter in Java? [duplicate]

    I know this is a rather old post but I have another slightly simpler solution. You could create another class within and make it abstract. Next make an Abstract method name it whatever you like. In the original class make a method that takes the new class as a parameter, in this method call the abstract method. It will look something like this.

  9. java - How to call a method with a string - Stack Overflow

    I am trying to use a string to call a method? Suppose I have a class called Kyle which has 3 methods: public void Test(); public void Ronaldo(); public void MakeThis(); And I have a string with the name of the method which I need to call: String text = "Test()"; Now I need to call the method whose name is inside of this string: Kyle k = new Kyle();

  10. reflection - java dynamically call methods - Stack Overflow

    VehicleConfiguration instance = new VehicleConfiguration(); Object returnObject = method.invoke(instance); // assuming no parameters To then call getName(), you need to cast the returned object to the type that has the method. Assuming getMake() is a method of the type VehicleMake, call it like this ((VehicleMake)returnObject).getMake();