• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

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.
0
gplana
Asked:
gplana
  • 2
  • 2
3 Solutions
 
CEHJCommented:
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
 
CPColinCommented:
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
 
gplanaAuthor Commented:
Thanks, but what does <?> means? Whould I write these characters litarally?
0
 
CPColinCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now