Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7752997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:56:29+00:00 2026-06-01T11:56:29+00:00

First time developing in Java, and first time developing for Android, so it’s quite

  • 0

First time developing in Java, and first time developing for Android, so it’s quite a newbie question.

I currently have this code:

public void onBtnClicked(View v){
    /** Handles button navigation */

    @SuppressWarnings("rawtypes")
    Class c;
    int viewId = v.getId();

    switch (viewId) {

    case R.id.btnNewTourny :
        c = NewTourny.class;
        break;
    case R.id.btnTeamEditor :
        c = EditTeam.class;
        break;
    case R.id.btnCatEditor :
        c = EditCat.class;
        break;
    case R.id.btnLoadTourny :
        c = EditCat.class;
        break;
    case R.id.btnNewCategory :
        c = NewCat.class;
        break;
    default :
        c = Main.class;
    }

    Intent myIntent = new Intent(v.getContext(), c);
    startActivityForResult(myIntent, 0);
}

Short question:

What does the .class property do, f.ex. in ‘c = NewTourny.class‘?

Why can’t I cast c as Tourny (which is the parent of all these classes)?

Long question:

This currently handles all button navigations throughout my app, and works fine. However, as you can see, I’ve suppressed a ‘rawtype’ warning, that comes when I cast c as a Class .
Now, I really want a code without warnings, so I thought ‘well, all these classes are a child of ‘Tourny”, so I thought it would work, casting c as Tourny – but that does not work. Then I realised, that I didn’t really know what the code “NewTourny.class” actually did, and that may be the clue to why I couldn’t cast c as Tourny. So, what does .class do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:56:32+00:00Added an answer on June 1, 2026 at 11:56 am

    It doesn’t really do much. NewTourney.class is more of a language specific way to write “the object which is the Class of NewTourney“. This shorthand allows one to refer to the class of a NewTourney, as opposed to dealing with specific already existing instances of NewTourney.

    In your specific case, I would hazard to guess that the Activity eventually creates an instance of the class to handle the action, or at least to hold the action’s context sensitive data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am first time developing an android app. Very new to this. I have
I'm a beginner in developing Android apps and it's the first time I'd be
I'm developing android on Mac OS. In the first time, I use android tool
First time I'm writing something here. I have a question that i hope someone
this is my first time to post a question here, I will try to
This is my first time developing a rails app from scratch. The goal of
Thank you all ahead of time. This is my first time developing a jQuery
Morning guys, So this is my first time developing a plugin for CakePHP. Here's
I've been developing my first iPhone app part-time and would like to start using
first time use JTree. Just wondering is it possible to have more than one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.