For instance I am running my main method with the following parameter (VM arguments)
Apple bad
class Client {
static String fruitName;
static String fruitQuality;
public static void main (String [] args){
fruitName=args[0];
fuitQuality=args[1];
}
}
In the above case I am able to capture the fruitName and fruitQuality that are passed as a runtime argument without any problem. But what if I want to access these values from a newly spawned thread of a different class, where accessing the static values from the class with main method (with a different thread )is not an option.
Note :Class IwantFruitInfo runs on a different Thread than the main thread
Class IWantFruitInfo(){
String fruitName;
String fruitQuality;
public void getValue(){
//Is there a way to use reflection to access and set the value for fruitName and fruitQuality here.
}
}
Aucun commentaire:
Enregistrer un commentaire