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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:56:09+00:00 2026-05-29T05:56:09+00:00

Consider this function: public static final int F(int a, int b) { a =

  • 0

Consider this function:

public static final int F(int a, int b) {
    a = a - 1 + b;
    // and some stuff
    return a;
}

Is it required for implementations of JVMs to execute - 1 before + b?

If we have a system profiler attached to the JVM, will we see the + b operation being carried out before the + 1 operation?

  • 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-29T05:56:10+00:00Added an answer on May 29, 2026 at 5:56 am

    Actually, I will disagree with the rest of the answers. The JLS §15.7 that people are referring to discusses the evaluation of operands. That is, in the expression

    x = foo() - 1 + bar()
    

    , in which order will the methods be invoked.

    The relevant section is §15.7.3, which specifies

    An implementation may not take advantage of algebraic identities such as the associative law to rewrite expressions into a more convenient computational order unless it can be proven that the replacement expression is equivalent in value and in its observable side effects […]

    Since the expression x = x - 1 + q is equivalent in all ways to x = x + q - 1, a conforming implementation is allowed to rewrite the expression (if it for some reason should decide that is more efficient).

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

Sidebar

Related Questions

Consider this trivial function: public static bool IsPositive(IComparable<int> value) { return value.CompareTo(0) > 0;
Consider this code : class App { public static function log($msg) { echo $msg;
Consider the following DllImport: [DllImport(lulz.so)] public static extern int DoSomething(IntPtr SomeParam); This is actually
Consider the TranslateAllCoords static function: static class CoordinateTransformation { public static void TranslateAllCoords(ref int
Consider: function Shape() { this.name = "Generic"; this.draw = function() { return "Drawing "
Consider the following base code: (function($) { $.fn.myPlugin = function(settings) { return this.each(function() {
Consider this code sample: public abstract class Parent { public int val; public Parent()
Consider this code: public function showActiveJobsAction($slug) { $em = $this->getDoctrine()->getEntityManager(); $category = $em->getRepository('JobeetBundle:Category')->findBySlug($slug); if
Consider this class: class Test { public $obj; function __construct ($obj) { $this->obj =
Consider this demo program: #include <stdio.h> class Base { public: virtual int f(int) =0;

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.