Get datatype?

Is there a way in an app to determine the datatype (string, integer..) of a variable and put type into a string variable? I know this is possible in C++.

Use the getClass() method.

variablename.getClass()

I previously tried that unsuccessfully.

Sorry, you want getObjectClassName(Object o)

2 Likes

Will that work for the basic data types, or whatever they are called (over 20 years since I learnt Java :slightly_smiling_face:). By that I mean variables that are not a pointer to an object.

Heck if I know :joy:. Victor added it because the getClass() was blocked.

You have an example of some working code?
VariableA pulled into RM from hub variables, no idea if its a integer or string
String B = getObjectClassName(VariableA) ??

Looks like String to me.

I want to determine if VariableA is a string or integer from inside app.

Just do

getObjectClassName(variableA)

OK we set now! Thanks.
String VariableB = getObjectClassName(VariableA)
VariableB returns java.lang.String

String VariableB = getObjectClassName(VariableA).replace("java.lang.", "")
VariableB returns String

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.