Incrementing and Decrementing : Operator « JSP « Java






Incrementing and Decrementing

<HTML>
  <HEAD>
    <TITLE>Incrementing and Decrementing</TITLE>
  </HEAD>

  <BODY>
    <H1>Incrementing and Decrementing</H1>
    <%
        int value1 = 0, value2 = 0;

        out.println("value1 = " + value1 + "<BR>");
        out.println("value2 = " + value2 + "<BR>");


        value2 = value1++;

        out.println("After <B>value2 = value1++</B>:" + "<BR>");
        out.println("value1 = " + value1 + "<BR>");
        out.println("value2 = " + value2 + "<BR>");

        int value3 = 0, value4 = 0;

        out.println("<BR>");
        out.println("value3 = " + value3 + "<BR>");
        out.println("value4 = " + value4 + "<BR>");

        value4 = ++value3;

        out.println("After <B>value4 = ++value3</B>:" + "<BR>");
        out.println("value3 = " + value3 + "<BR>");
        out.println("value4 = " + value4 + "<BR>");
     %>
  </BODY>
</HTML>

           
       








Related examples in the same category

1.Adding value
2.Checking Operator Precedence
3.Using Logical Operators
4.Using Relational Operators
5.Addition and Subtraction
6.Multiplication and Division
7.Using Operators