Questions tagged [method-invocation]
135 questions
3
votes
2 answers
Java: How to call a function whose name is stored in a string variable
I have a generic string stored in a variable String func = "validate"; and i want to call the function of that name ie, i need to call validate() function. I mean to say i will pass the variable to some function
public void callFunc(String…

Shams Ud Din
- 99
- 2
- 8
2
votes
4 answers
Method Local Inner Class
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
…

Omnipotent
- 27,619
- 12
- 30
- 34
2
votes
2 answers
Why does it seem to call the wrong method?
Lets say I have two classes A and B . B inherits from A and B has the following methods:
public boolean equals(Object other) {
System.out.print("Object");
return true;
}
public boolean equals(A other){
System.out.print("A object");
…

bm1125
- 223
- 1
- 10
2
votes
1 answer
Exact overload resolution procedure - why f(1) call against f(int... arg) and f(long... arg) is not ambiguous?
I feel that these are applicable:
JLS 15.12.2.4. Phase 3: Identify Methods Applicable by Variable
Arity Invocation
JLS 15.12.2.5. Choosing the Most Specific Method
But JLS language is so complex that I cannot understand the point.
void…

Code Complete
- 3,146
- 1
- 15
- 38
2
votes
2 answers
C++ call class method from within class
I have a class that implements a linked list. The class has a find() method which finds a value if it exists in the linked list. I have another method add() which adds a node, but ONLY if that value contained in that node does NOT already exist in…

Ben
- 553
- 1
- 13
- 25
2
votes
3 answers
Why can't I call this method via string?
Question from a Reflection newbie. I have a method in a Windows Form:
private void handleOrderCode()
{
//...do stuff
}
Which I am trying to call in the following manner:
Type t = this.GetType();
MethodInfo mi = t.GetMethod("handleOrderCode");
if…

One Monkey
- 713
- 3
- 9
- 24
2
votes
3 answers
Java invoke method using reflection
I am trying to invoke a method using reflection.
The method I am invoking is not static and in the same class I am invoking it from.
A simplified version of my code:
public class Test {
public static void main(String[] args) {
Test instance…

Jdv
- 962
- 10
- 34
2
votes
2 answers
Invoke Methods Dynamically on Java
At work, we have to generate a report for our client that changes its parameters several times during the week.
This report is generated from a single table on our database.
For example, imagine a table that has 100 columns and I have to generate a…

Victor Dinis
- 111
- 1
- 5
2
votes
1 answer
Can I create an object that receives arbitrary method invocation in python?
In python, can I create a Class that, when instantiated, can receive arbitrary method invocation? I have read this but couldn't put the pieces together
I guess it has something to do with the attribute lookup. For a class Foo:
class Foo(object):
…

user2829759
- 3,372
- 2
- 29
- 53
2
votes
1 answer
Why calling this function recursively does not throw a NullPointerException
My question comes from this thread.
Consider this code:
public class Test {
static Function fibLambda = null;
public static void main (String[] args) {
fibLambda = n -> n <= 2 ? 1 : fibLambda.apply(n - 1) +…

user2336315
- 15,697
- 10
- 46
- 64
2
votes
5 answers
Java performance issue
I've got a question related to java performance and method execution.
In my app there are a lot of place where I have to validate some parameter, so I've written a Validator class and put all the validation methods into it. Here is an…

Colby77
- 617
- 1
- 8
- 10
2
votes
3 answers
Can I check if a void method returned?
I just want to ask, if it is possible to check if a void method "cancelled" itself by calling return;?
For example in my main I call calculate(myArray);, which is defined as follows:
public static void calculate(Object[] array) {
if (array ==…

Frozn
- 539
- 1
- 8
- 17
2
votes
2 answers
invoke javax.el.MethodExpression from jsf component
I have a jsp tag which takes a javax.el.MethodExpression as attribute:
<%@ attribute name="action" required="true" type="javax.el.MethodExpression" rtexprvalue="true" %>
within the same tag I have:
link…

marcosbeirigo
- 11,098
- 6
- 39
- 57
2
votes
2 answers
Difference between this two uses of MethodInvoker
What exactly is the difference between this two uses of MethodInvoker:
1:
textBox1.Invoke(new MethodInvoker(b));
2:
textBox1.Invoke((MethodInvoker)delegate { b(); });
I only understand, that variant 2 allow me to call b() with parameters if i…

krokvskrok
- 197
- 2
- 10
2
votes
3 answers
Generic method invokation
If we have generic method
class SClass{
public static ArrayList listFactory(){ return new ArrayList(); }
}
we can define type-parameter T explicit when this method is calling.
SClass.>listFactory();//compile…
user2889159