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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:26:23+00:00 2026-06-12T11:26:23+00:00

Arrays are not a primitive type in Java, but they are not objects either

  • 0

Arrays are not a primitive type in Java, but they are not objects either, so are they passed by value or by reference? Does it depend on what the array contains, for example references or a primitive type?

  • 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-12T11:26:24+00:00Added an answer on June 12, 2026 at 11:26 am

    Your question is based on a false premise.

    Arrays are not a primitive type in Java, but they are not objects either … “

    In fact, all arrays in Java are objects1. Every Java array type has java.lang.Object as its supertype, and inherits the implementation of all methods in the Object API.

    … so are they passed by value or by reference? Does it depend on what the array contains, for example references or a primitive type?

    Short answers: 1) pass by value, and 2) it makes no difference.

    Longer answer:

    Like all Java objects, arrays are passed by value … but the value is the reference to the array. So, when you assign something to a cell of the array in the called method, you will be assigning to the same array object that the caller sees.

    This is NOT pass-by-reference. Real pass-by-reference involves passing the address of a variable. With real pass-by-reference, the called method can assign to its local variable, and this causes the variable in the caller to be updated.

    But not in Java. In Java, the called method can update the contents of the array, and it can update its copy of the array reference, but it can’t update the variable in the caller that holds the caller’s array reference. Hence … what Java is providing is NOT pass-by-reference.

    Here are some links that explain the difference between pass-by-reference and pass-by-value. If you don’t understand my explanations above, or if you feel inclined to disagree with the terminology, you should read them.

    • http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/topic/com.ibm.xlcpp8a.doc/language/ref/cplr233.htm
    • http://www.cs.fsu.edu/~myers/c++/notes/references.html

    Related SO question:

    • Is Java "pass-by-reference" or "pass-by-value"?

    Historical background:

    The phrase “pass-by-reference” was originally “call-by-reference”, and it was used to distinguish the argument passing semantics of FORTRAN (call-by-reference) from those of ALGOL-60 (call-by-value and call-by-name).

    • In call-by-value, the argument expression is evaluated to a value, and that value is copied to the called method.

    • In call-by-reference, the argument expression is partially evaluated to an “lvalue” (i.e. the address of a variable or array element) that is passed to the calling method. The calling method can then directly read and update the variable / element.

    • In call-by-name, the actual argument expression is passed to the calling method (!!) which can evaluate it multiple times (!!!). This was complicated to implement, and could be used (abused) to write code that was very difficult to understand. Call-by-name was only ever used in Algol-60 (thankfully!).

    UPDATE

    Actually, Algol-60’s call-by-name is similar to passing lambda expressions as parameters. The wrinkle is that these not-exactly-lambda-expressions (they were referred to as “thunks” at the implementation level) can indirectly modify the state of variables that are in scope in the calling procedure / function. That is part of what made them so hard to understand. (See the Wikipedia page on Jensen’s Device for example.)


    1. Nothing in the linked Q&A (Arrays in Java and how they are stored in memory) either states or implies that arrays are not objects.

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

Sidebar

Related Questions

I read that Python does not actually support 2D arrays but rather an array
Possible Duplicate: Java: Array of primitive data types does not autobox I've been doing
Are arrays merely objects in disguise? Why/why not? In what way(s) are they (such/not)?
I have three arrays (it's written in C but that is not important, it
Because shells other than ksh do not support pass-by-reference, how can multiple arrays be
I use an external module ( libsvm ), which does not support numpy arrays,
Why does the array a not get initialized by global variable size ? #include<stdio.h>
When you do Something.find(array_of_ids) in Rails, the order of the resulting array does not
How do I initialize a multi-dimensional array of a primitive type as fast as
I have a number of one dimension arrays of Object[] (these objects are primitive

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.