?
Solved

What does .class mean ?

Posted on 2014-02-26
5
Medium Priority
?
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 400 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 1600 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 1600 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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