How to properly use increment operator in Java?

Viewed 14

I'm a high school student learning AP Computer Science A Java. I encountered a problem but I don't know how to explain it:


    class Test
{
  public static void main(String[] args)
  {
  int a = 5;
  
  System.out.println(a++);
  
  }
  }

In this case, a++ should automatically make the value of a increase by 1, so System.out.println(a++); should print 6 instead of 5. But when I compile it, it still prints 5. Why is that?

0 Answers
Related