This question already has an answer here:
I have looked up reflections in java, but still don't quite understand them. I need to "swap" values of two local parameters using a reflection. Here is what I have. I know it doesn't swap the values which is why I need to use the reflection. How do I do this?
public class SwapBla {
static int x = 1;
static int y = 2;
public static void swap2(int x, int y)
{
int temp = x;
x = y;
y = temp;
}
}
Aucun commentaire:
Enregistrer un commentaire