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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:06:40+00:00 2026-05-10T23:06:40+00:00

You can do it in .NET by using the keyword ref. Is there any

  • 0

You can do it in .NET by using the keyword ‘ref’. Is there any way to do so in Java?

  • 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. 2026-05-10T23:06:40+00:00Added an answer on May 10, 2026 at 11:06 pm

    What are you doing in your method? If you’re merely populating an existing array, then you don’t need pass-by-reference semantics – either in .NET or in Java. In both cases, the reference will be passed by value – so changes to the object will be visible by the caller. That’s like telling someone the address of your house and asking them to deliver something to it – no problem.

    If you really want pass-by-reference semantics, i.e. the caller will see any changes made to the parameter itself, e.g. setting it to null or a reference to a different byte array, then either method needs to return the new value, or you need to pass a reference to some sort of ‘holder’ which contains a reference to the byte array, and which can have the (possibly changed) reference grabbed from it later.

    In other words, if your method looks likes this:

    public void doSomething(byte[] data) {     for (int i=0; i < data.length; i++)     {         data[i] = (byte) i;     } } 

    then you’re fine. If your method looks like this:

    public void createArray(byte[] data, int length) {     // Eek! Change to parameter won't get seen by caller     data = new byte[length];      for (int i=0; i < data.length; i++)     {         data[i] = (byte) i;     } } 

    then you need to change it to either:

    public byte[] createArray(int length) {     byte[] data = new byte[length];      for (int i=0; i < data.length; i++)     {         data[i] = (byte) i;     }     return data; } 

    or:

    public class Holder<T> {     public T value; // Use a property in real code! }  public void createArray(Holder<byte[]> holder, int length) {     holder.value = new byte[length];      for (int i=0; i < length; i++)     {         holder.value[i] = (byte) i;     } } 

    For more details, read Parameter passing in C# and Parameter passing in Java. (The former is better written than the latter, I’m afraid. One day I’ll get round to doing an update.)

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

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The simplest way is to do it like so (assuming… May 11, 2026 at 8:35 pm
  • Editorial Team
    Editorial Team added an answer This seems to work ($i being the filename up to… May 11, 2026 at 8:34 pm
  • Editorial Team
    Editorial Team added an answer It's probably the <br> which is creating the sub-cells. Try… May 11, 2026 at 8:34 pm

Related Questions

Being primarily a C++ developer the absence of RAII (Resource Acquisition Is Initialization) in
I have a user interface in .net which needs to receive data from a
I have a PHP script (running on a Linux server) that ouputs the names
.NET allows to extend XSLT by using the so called extension object. Very handy

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.