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

  • Home
  • SEARCH
  • 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 6789371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:35:46+00:00 2026-05-26T17:35:46+00:00

While developing a web application in JSF, I came across an expression which was

  • 0

While developing a web application in JSF, I came across an expression which was evaluated in a way that I couldn’t follow. Let’s represent the same expression with a simple Java code.

final public class Main
{
    public static void main(String[] args)
    {            
        int x=5;
        int temp=10;

        temp=temp + 1 + x;
        System.out.println("temp = "+temp);

        int var=10;
        var=var++ + x;
        System.out.println("var = "+var);
    }
}

In the above simple code snippet, the first case is obvious and it displays the value 16 through the statement System.out.println("temp = "+temp);. There is no question at all about it but in the second case, I have represented the same thing using the shorthand operator ++ (var++) and that causes the value 15 to be displayed on the console instead of displaying 16. How is this expression evaluated here?


Here, there is an obvious thing that should be mentioned. In the expression var++, 10 is first passed and that value (not 11) is used to evaluate the entire expression on the right of the assignment which is in this case var++ + x and then var is incremented by 1. Accordingly, the assignment to itself (var) can not be observed here.
Where was the incrementation lost?

  • 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-26T17:35:46+00:00Added an answer on May 26, 2026 at 5:35 pm

    Post increment operator like x++ means first you use the value x then you increment and in our case

     var=var++ + x;
    

    assignment takes precedence.
    Try this

     var=++var + x;
    

    and you should get the value of 16.

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

Sidebar

Related Questions

While developing a WinForms application, I came across what I believe is a bug
I'm currently developing a web application that has one feature while allows input from
Which IoC to consider while developing ASP.NET Web application project and what are the
While developing a C++ application, I had to use a third-party library which produced
I'm developing a Grails (Version 1.3.3) Web-Application using the Grails Spring-Security Plugin, Spring-Security-Core-1.0.1 (which,
I am developing a web application that can support threaded comments. I need the
What is the best windows environment to use while developing web application with heavy
I am using IIS7 Express while developing my web application. I need to use
Guys I am currently developing a web application, in which rules, which are basically
I am in the processing of developing a web application which will integrate directly

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.