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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:46:23+00:00 2026-05-30T15:46:23+00:00

I have a programming competition tomorrow and I have a quick question: In Java,

  • 0

I have a programming competition tomorrow and I have a quick question:

In Java, if you would pass an object in a parameter for a method, you actually got not a copy of the object, but the actual object.

Is it the same as C#?

public static void PunchyManager(string[] inputArray, ref int a, ref int b)
{
            string[] tempStrArray = inputArray;
}

If I do that will I basically make a pointer to inputArray, instead of having a copy?

Just a quick question, 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-05-30T15:46:25+00:00Added an answer on May 30, 2026 at 3:46 pm

    In regard to your basic question in relation to Java Yes.

    More generally Yes and no. Reference types (classes) are passed by reference which is like a single pointer. For something that can truly modify references outside the caller you should use the ref keyword even on reference types. This is similiar to a double pointer (assuming we are referring to pointers as they work in C for our pointer analogies).

    class RefRefExample
    {
        static void Method(ref string s)
        {
            s = "changed"; 
        }
        static void Main()
        {
            string str = "original";
            Method(ref str);
            // str is now "changed"
        }
    }
    

    In the above example if we passed str without using the ref keyword we would reassign the local reference of s instead of the original reference of str. By passing our reference by reference we can modify the original reference outside of the function as well. References themselves are still copied by value (but the copied reference still points to the same value) without the ref keyword.

    http://msdn.microsoft.com/en-us/library/14akc2c7(v=vs.80).aspx


    For practical usage in the scenario you are describing the modern C# idiom usually uses lists and they will likely be much faster to use as far as programming in your competition:

    public static void PunchyManager(List<string> inputList, ref int a, ref int b)
    {
        var tempList = new List<string>();
        foreach (var item in inputList)
           tempList.Add(item);     
    }
    

    Working on the original input list would modify objects through the reference so you would be affecting the original values outside of the method whereas the templList is a copy – Lists are very convenient.
    Furthermore you can convert them back to Arrays using .ToArray()

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

Sidebar

Related Questions

I've been practicing for an upcoming programming competition and I have stumbled across a
I have been programming in Python, PHP, Java and C for a couple or
I have been programming in Java since 2004, mostly enterprise and web applications. But
I have been programming in C# and Java for a little over a year
My university is hosting a Programming Competition, and have decided to support Turbo C
Another question in large scale programming: I have a job queue with time stamps
I am new to C++ and have programming knowledge only in Java. Can anyone
I have been programming in Java for a while, but have never dealt with
I am participating in a big programming competition tomorrow where I use R. Time
I'm trying to solve a programming problem to practice for a competition tomorrow, and

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.