Convert C# generic into Java generic?

Wherever you call your method: C# MyEnum value = TemplateMethod("AnEnumValue") In Java you can do it like this: Java MyEnum value = MyEnum. ValueOf("AN_ENUM_VALUE") If you're worried about case, and if you follow Java conventions of using upper case enum values, then you can just do this: MyEnum value = MyEnum. ValueOf(anEnumValue.toUpperCase()) To encapsulate it in a method: static > E parse(Class enumType, String value) { return (E)Enum.

ValueOf(enumType, value.toUpperCase()); } Call it like this: MyEnum value = parse(MyEnum. Class, anEnumValue).

Wherever you call your method: // C# MyEnum value = TemplateMethod("AnEnumValue"); In Java you can do it like this: // Java MyEnum value = MyEnum. ValueOf("AN_ENUM_VALUE"); If you're worried about case, and if you follow Java conventions of using upper case enum values, then you can just do this: MyEnum value = MyEnum. ValueOf(anEnumValue.toUpperCase()); To encapsulate it in a method: static > E parse(Class enumType, String value) { return (E)Enum.

ValueOf(enumType, value.toUpperCase()); } Call it like this: MyEnum value = parse(MyEnum. Class, anEnumValue).

First change your method signature to the following : private T TemplateMethod(String value).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions