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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:52:48+00:00 2026-06-07T18:52:48+00:00

Scenario: Lets say I’ve a Person class. I also have GetPersonDetail function on one

  • 0

Scenario:

Lets say I’ve a Person class. I also have GetPersonDetail function on one of the Helper class.

So is it necessary to new up the Person class or is it ok to do as below.

Person person=null;

person= Helper.GetPersonDetail();

OR

Person person = new Person();
person=Helper.GetPersonDetail();

Both seems to work, just wondering if there are any unexpected consequences of the option one above.

Thanks.

  • 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-07T18:52:50+00:00Added an answer on June 7, 2026 at 6:52 pm

    You shouldn’t create a new object before getting it from the method. The object that you created will just be thrown away when you assign the result of the method to the variable, so creating an object first is just a waste.

    Normally nothing harmful happens from creating an instance in vain, but if it needs some cleanup before being removed (for example disposing), it wont happen for that instance.

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

Sidebar

Related Questions

Lets say i have the following scenario: public class A { public String createString(final
Lets say I have a set of model classes like this: public class Person
I came across this scenario. We have a class lets say Main having a
Scenario 1 I have one table lets say member. In that table member i
I am using backbone.js here is my scenario Lets say I have a view
So lets say I have the following scenario. http://website.com:8080 and http://website.com:8080/demo Is there any
Maybe it's not worth worrying about in this scenario, but lets say you have
Lets take a static html page as a scenario, lets say you have a
Lets say I have some view models set up as follows: public class User
I have following scenario: Lets say we have two different webparts operating on the

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.