public static void main(String args[]){
Scanner s = new Scanner(System.in);
int x;
int y;
int z = 0;
x = s.nextInt();
y = s.nextInt();
while(y != 0){
z += x;
y--;
}
System.out.println(z);
}
This is all. This code calculates x*y but doesn't use *. It was just a (task ?) somebody told me. And my question is why this is working with negative numbers. That x can be negative is obvious but why can y be.
Edit: I wrote this code on my own so I know why it works without *. That's not the question. I can input 5 for x and -5 for y and i get -25. But why? Everytime he adds one more time x to z y goes 1 down. But after the 5th time it stops.