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

The Archive Base Latest Questions

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

import java.util.Arrays; public class Test { public static void main(String… args) { String[] strings

  • 0
import java.util.Arrays;
public class Test {
    public static void main(String... args) {
        String[] strings = new String[] { "foo", "bar" };
        changeReference(strings);
        System.out.println(Arrays.toString(strings)); // still [foo, bar]
        changeValue(strings);
        System.out.println(Arrays.toString(strings)); // [foo, foo]
    }
    public static void changeReference(String[] strings) {
        strings = new String[] { "foo", "foo" };
    }
    public static void changeValue(String[] strings) {
        strings[1] = "foo";
    }
}

Can anyone explain these questions?

  1. What is Strings[]. Is it a String Object or String Object containing array of Objects.
  2. What does the changeReference() and changeValue() functions do and return?
  3. Does Java support Pass by Reference?
  • 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-22T23:06:14+00:00Added an answer on May 22, 2026 at 11:06 pm
    1. strings is an array of Strings. Arrays are objects for our purposes here, which means they are a reference type.

    2. changeReference does nothing useful. It receives a reference to strings, but it receives that reference by value. Reassigning strings within the function has no effect on the strings being passed in — it just replaces the local copy of the reference, with a reference to a new array. changeValue, on the other hand, modifies the array object referred to by strings. Since it’s a reference type, the variable refers to the same object.

    3. No, “pass by reference” is not supported. Java can pass references around, but it passes them by value. Summary being, you can change the object being passed in, but you can’t replace the object in such a way that the caller will see it.

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

Sidebar

Related Questions

import java.io.UnsupportedEncodingException; import java.util.Arrays; public class Main { public static void main(String[] args) {
import java.util.*; public class Test { public static void main(String[] args) { Map<String,String> map
import java.util.scanner; import javax.swing.JOptionPane; public class FirstHomeJavaApplet{ public static void main(String[] args){ int num1=2;
import java.util.Scanner; class Practice { public static void main(String args[]) { System.out.println(Enter the number
package homework5; import java.io.*; import java.util.Arrays; public class Main { /** * @param args
I have the following Java code: import java.util.Arrays; import java.util.Collections; public class Test {
import java.lang.reflect.*; import java.util.Arrays; class Test { class Inner { public <T> Inner(T arg)
import java.util.ArrayList; import java.util.Arrays; public class Cloud { private ArrayList<Point> points; private double left;
import java.util.*; import org.directwebremoting.util.Logger; public class People { public People() { people = new
Why does my code not work? package generatingInitialPopulation; import java.util.Arrays; import java.util.Collections; public class

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.