Solved

What does .class mean ?

Posted on 2014-02-26
5
362 Views
Last Modified: 2014-02-26
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
Comment
Question by:gplana
  • 2
  • 2
5 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 100 total points
ID: 39889709
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
 
LVL 14

Accepted Solution

by:
CPColin earned 400 total points
ID: 39890007
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
 
LVL 15

Author Comment

by:gplana
ID: 39890026
Thanks, but what does <?> means? Whould I write these characters litarally?
0
 
LVL 14

Assisted Solution

by:CPColin
CPColin earned 400 total points
ID: 39890030
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
 
LVL 15

Author Comment

by:gplana
ID: 39890082
Great, thank you very much.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
stringclean challenge 26 56
nini micro sd card issues 9 63
word0 challenge 3 58
Unable to start eclipse ? 17 86
Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now