Can I get an explanation to understand this better:
I can see that this is working :

```
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
int counter = 0;
double mean;
for (; true; counter++) {
String input = reader.readLine();
if (input.equals("-1"))
break;
int numbers = Integer.parseInt(input);
sum += numbers;
}
mean = (double) sum / counter;
System.out.println(mean);
```

And this isn't :
```
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int avg = 0;
double sum;
double mean =0 ;
while (true){
int number = Integer.parseInt(reader.readLine());
sum=+number;
if ( number== -1){
break;
}
avg++;
mean = (sum/avg);
}
System.out.println(mean);
}
}
```

Double.parseDoublefor input double numbers...