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

  • Home
  • SEARCH
  • 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 8901027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:14:50+00:00 2026-06-15T01:14:50+00:00

I have noticed that there are two ways to cast objects (the difference is

  • 0

I have noticed that there are two ways to cast objects (the difference is the placement of the outer parenthesis):

 1. SimpleType simpleType = ((SimpleType) (property.getType()));
 2. SimpleType simpleType = ((SimpleType) property).getType();

Are they doing the same thing ?

  • 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-15T01:14:51+00:00Added an answer on June 15, 2026 at 1:14 am

    Are they doing the same thing ?

    No they are not.

    • The first one is casting your value returned from
      property.getType() to SimpleType. (Invocation is done before Casting)
    • The second one is first casting your property to SimpleType and
      then invoking the getType() method on it. (Casting is done before Invocation).

    You can also understand it from the precedence of parenthesis. Since it has the highest precedence, it will be evaluated first.

    First Case: –

    So, in ((SimpleType) (property.getType()));: –

    (property.getType())
    

    is evaluated first, then the casting is performed. In fact you don’t really need a parenthesis around that. (property binds tighter to the dot (.) operator than the cast operator). So, invocation will always be done before casting. Unless you force it to reverse as in the below case: –

    Second Case : –

    In ((SimpleType) property).getType(): –

    ((SimpleType) property)
    

    is evaluated first, then the invocation is done. As, now you have enclosed property inside the brackets, due to which it binds tighter to the cast operator, due to higher precedence enforced by parenthesis.

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

Sidebar

Related Questions

I have noticed that there are strange requests to my website trying to find
I am implementing the superfish menu and have noticed that there is a funny
I have facebook comments on my site. I noticed that when there are 10
I have noticed that if I have a unique compound keys for two columns,
I was looking at some lint errors and notice that there are two ways
I have noticed that in the SlimDX.Direct3D9 namespace there is a lot of classes
Possible Duplicate: ASP.NET: Web Site or Web Application? I have noticed that there is
I have noticed that there is an asymmetry between the signature used to distinguish
I've noticed that if I have two links : <a href=#>Text</a> <a href=#>Text</a> They
We have noticed that component publishing takes a long time. The component we are

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.