object package from object name

Say I had:

int num;

double dec;

String str;

ArrayList arr;

Object obj;

I want to take a String that is the name of an Object and return a String that is the package of the Object.

For example, if the String was "arr", the method would return "java.util.ArrayList".

I looked at the Reflection API, but I couldn't find anything that did this. How do I do this?

[414 byte] By [jaaaavaaaa] at [2007-10-2 20:34:51]
# 1

Objects don't have names. There's no association from an object to the names of the variables that are pointing at it, and reflection does not work on method variables.

If those are member variables, then you can use reflection to get their types.

http://java.sun.com/docs/books/tutorial/reflect/

jverda at 2007-7-13 23:18:02 > top of Java-index,Java Essentials,Java Programming...