How to get the string value of a parameter in Java? -
i'm trying save parameter property, parameter : testspeed ( = "20" )
, , have method :
saveproperty(string parameter)
which save value of parameter file, :
saveproperty(testspeed);
my property file looks :
testspeed : 20 testheight : 300
my question : in java possible name of parameter, in case parameter passed saveproperty()
testspeed
, , it's name "testspeed"
, how string inside of saveproperty()
, don't have following save :
saveproperty(string name,string value);
and call :
saveproperty("testspeed",testspeed)
also, when need out property file, can call :
getproperty(testspeed)
i know how use property file, i'm using example, maybe caused confusion when mentioned property file.
the essence of question : how name of parameter passed method.
void somemethod(string parameter_xyz) { // in here if call somemethod(testspeed), how string "testspeed", // not it's value, it's name, // spelled "testspeed" ? }
is doable in java ?
first of correct format of property file this:
testspeed=20 testheight=300
now pull property need pass key name, you're doing in saveproperty(string name, string value)
method. if understood question correctly want avoid passing property name. can have custom methods this:
void savetestspeed(string value) { saveproperty("testspeed", value); } strig gettestspeed() { getproperty("testspeed"); }
edit: based on edited question.
no not possible in java.
please remember java strictly pass-by-value makes impossible figure out name of actual variable name @ callee's end. inside saveproperty
method can value of arguments since in java object references passed value not name.
this not practical since there nothing stops method being called like:
savepropery( "20" );
in case should name of property?
Comments
Post a Comment