What does .class mean ?

Hi.

I'm starting to program in Android. When using tabs, I have this line of code:

tabHost.addTab(tabHost.newTabSpec(i + "").setIndicator(names[i]), myClass.class, b);

Open in new window


What does the .class mean? Can I make an array of a set of classes with the .class? For example:
   myArray[0] = myClass.class;
   myArray[1] = myOtherClass.class;
etc... ?

Open in new window

In this case, which type should be declared this array?

Thank you.
LVL 15
gplanaAsked:
Who is Participating?
 
CPColinConnect With a Mentor Senior Java ArchitectCommented:
In this case, which type should be declared this array?

The .class value associated with every object is an instance of java.lang.Class, so you'd make an array using something like this:

Class<?>[] classes = new Class<?>[2];

Open in new window

0
 
CEHJConnect With a Mentor Commented:
Every object in Java has one (and the same) class object associated with it. X.class refers to that class object connected to an instance of X
0
 
gplanaAuthor Commented:
Thanks, but what does <?> means? Whould I write these characters litarally?
0
 
CPColinConnect With a Mentor Senior Java ArchitectCommented:
The <?> has to do with a concept in Java called "generics." You probably don't have to start worrying about them quite yet. But yes, you'd type those characters in exactly as shown.
0
 
gplanaAuthor Commented:
Great, thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.