I HAVE DOUBT IF WRITE PRINT(DATA--) THEN IT IS GIVING ERROR BUT WHEN I AM WRITING PRINT(DATA-1) THEN IT IS WORKING WHY S0?

package recursion;

public class recursion1 {
public static void print(int data)
{
if(data==0)
{
return;
}
System.out.println(data);
print(data–);
}

public static void main(String[] args) {
print(5);
}
}

see this

 public static void main(String[] args) {
    int x=5;
    System.out.println(x-1);
    System.out.println(x--);
    System.out.println(x);
    }

see this print 4 then 5 then 4 cause Well, although the value of x will be same, they are different operators, and use different JVM instructions in bytecode. x-- is postfix decrement operator, this means that the value of x is first used in the program and then decremented so it becomes a long loop for your code and hence the error