I want to use:
user_update("lastlogin", INT);
user_update("nick", STRING);
user_update("money" DOUBLE);
but in one class:
public void update_user(String what, String value){
[...]
}
So here is my question : How can I handle INT, STRING, DOUBLE in class?
public void update_user(String what, String/int/double value){
[...]
}
You may as well use a generic method
public <T> void update_user(String what, T value) {}
This may be useful if you are intended to add more types used by the method in the future. Using generics may save you from writing too much boilerplate code.
You can use Object.
public void update_user(String what, Object value){}
Take a look here
java.lang.Object
OR
you can implement 3 methods:
public void update_user(String what, String value){}
public void update_user(String what, int value){}
public void update_user(String what, double value){}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With