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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:28:34+00:00 2026-06-15T05:28:34+00:00

I was browsing through the Java code today and I noticed something. int[] m

  • 0

I was browsing through the Java code today and I noticed something.

int[] m = mag;
int len = m.length;
int[] xm = xInt.mag;
if (len != xm.length)
    return false;

(This is in the BigInteger class, which can be found by unzipping src.zip. It’s in the equals method.) Why is an entirely new variable m created when it is only used once? Why isn’t the code just int len = mag.length? I saw this in another method also (bitLength), and again, m is only used once. Is there any advantage to doing this or is it just a mistake by the creators of this class?

Edit: as @usernametbd pointed out, it is used a bit later:

for (int i = 0; i < len; i++)
    if (xm[i] != m[i])
        return false;

But they still could have just used mag. Why would an entirely new variable be made?

In a different function (in the same class, bitLength), a new variable m is made and it’s only used a single time.

  • 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-15T05:28:35+00:00Added an answer on June 15, 2026 at 5:28 am

    Because mag is a field, m is local variable. Access to local variable may be faster, though modern JITs can create such a substitute local variable automatically.

    BTW you should have tell what the method you had in mind (I found it to be equals()), and cite original source (it is available) rather than decompiled one.

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

Sidebar

Related Questions

While browsing through the source code of the java.util.concurrency package, I noticed an idiomatic
Browsing through the source code of Microsoft's sample StockTrader application, I found this snippet
I was browsing the Internet for random Java code, and I found this source
Hi all I was browsing through some of the Java source code when I
I was browsing through the questions and noticed this: SELECT prodid, issue FROM Sales
As I'm browsing through a Rails source code, it contains the line: @@autoloads =
Browsing through Guava libraries I saw this weird signature on the readLines method of
I was browsing through one site called BSEINDIA.com ( http://www.bseindia.com/stockreach/stockreach.htm?scripcd=532667 ), i Noticed that
Browsing through Coding Horror, I saw this article on removing the user field from
I was just browsing through some of my own code in Telerik's JustDecompile 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.