Skip to main content

Type casting

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
phil1234
Offline
Joined: 2011-07-15

Hi,

I got a method

public <D> doSomething(String value, Class<D> clazz) {
    D convertedValue = convert(value, clazz);
}

Does anyone know how to write a general method convert() that converts the String value to clazz?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
OneJumpedUp
Offline
Joined: 2012-04-05

Hey
See reply I gave to "How do I give a generic variable a value?"