0

My primary goal here is just to have an Arraylist or array that holds type Class. What would the easiest way to go about this?

I don't really want to create an object to just to call getClass().

Class[] classes = { someObject.getClass(), someObject1.getClass() };

The most ideal way to do this would be just to just call the name of the class. Is this possible?

Class[] classes = { SomeObject, SomeObject1 };

The reason why I want to do this is because I have a static object that I hold onto and I want to see if it is an instanceOf whatever is in my array.

2 Answers 2

5

Yes it's possible.

Class[] classes = { SomeObject.class, SomeObject1.class };
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I definitely looked passed this.
1

I'm not sure what you are trying to achieve, but maybe this will help:

Class[] classes = {SomeObject.class, SomeObject1 .class };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.