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 8580623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:52:05+00:00 2026-06-11T20:52:05+00:00

My colleague asks me a question which I can’t find the final answer myself,

  • 0

My colleague asks me a question which I can’t find the final answer myself, the question is about object casting.

Say I have a class A, and a Factory class, In the factory class, I want to create the A instance:

Public class Factory {

    public A createA1() {
       Object instance = get_A_Object();
       //Single casting
       return (A) instance;
    }

     public A createA2() {
       Object instance = get_A_Object();
       // Duplicate casting or more
       return (A) (A) instance;
    }
}

My question is:

What’s the different between single casting in method createA1() vs duplicate casting in method createA2()? Do they always get the same result?

EDIT:

To clarify, my colleague asks me about this line of code:

org.omg.CORBA_2_5.ORB orb = ((org.omg.CORBA_2_5.ORB)org.omg.CORBA.ORB.init((String[])localObject2, localProperties)); 
return (org.omg.CORBA_2_5.ORB)(org.omg.CORBA_2_5.ORB)(org.omg.CORBA_2_5.ORB)(org.omg.CO‌​RBA_2_5.ORB)(orb);
  • 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-11T20:52:06+00:00Added an answer on June 11, 2026 at 8:52 pm

    That duplicate is completely redundant. You only have to cast once.

    Here’s an exercise. If you load this in your IDE, and remove the casts one-by-one, at what point does it start complaining about your types ?

    In fact, in your amended question, you don’t have to cast at all!

    org.omg.CORBA_2_5.ORB orb = ((org.omg.CORBA_2_5.ORB)org.omg.CORBA.ORB.init((String[])localObject2, localProperties));
    

    You’ve declared orb‘s type in the assignment.

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

Sidebar

Related Questions

A colleague mentioned that he heard about a lightweight collection which would automatically page
My colleague and I have been having a discussion about what Collections should be
Colleague has asked the question and we were unable to find it - on
A colleague has a stash in their repository which I can access (via the
A colleague and I have been partnered on a project for school, in which
A colleague of mine came across an article on codeproject over the weekend which
A colleague has a batch script program which needs to to run on a
A colleague asked me, if you have a table in SQL Server with only
My colleague wrote the following stackoverflow question: other stack overflow question on this topic
A colleague of mine told me about a little piece of design he has

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.