Can you help? I tried to output max, min and average variables of massive | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you help? I tried to output max, min and average variables of massive

package com.company; public class Main { public void main (String[] args){ int l = 100; double [] massive = new double [l]; double minimum = 0; double maximum = 0; double summary = 0; for (int i = 0; i < l; i++) { massive [i] = Math.random(); if (massive[i] < minimum) { minimum = massive[i]; } if (massive[i] > minimum) { maximum = massive[i]; } summary = summary + massive[i]; } double average = summary/l; System.out.println(maximum); System.out.println(minimum); System.out.println(average); } } It outputs to console java.lang.NullPointerException: null receiver What I did wrong? I tried to google this, but I don't know where null there.

12th Feb 2022, 3:41 AM
Дмитрий Нуйков
Дмитрий Нуйков - avatar
1 Answer
+ 5
No exception working fine. You just missed to make void method static
12th Feb 2022, 4:47 AM
A͢J
A͢J - avatar