How to avoid overriding?
Hallo guys, I have written a programm in which I want to store points in an array by using a methode. My code: //created an object Student s1=new Student(); //calling the method inputPoints s1.inputPoints(3); s1.inputPoints(1); public class{ int counter; int[]n; int average; int sum; public float inputPoints(int p) { counter++; n=new int[counter]; for(int i=0;i<counter;i++) { n[i]=note; } for(int i=0;i<counter;i++) { sum+=n[i]; } average=average/counter; return average; } I am getting as an input 2.5, but the average should be 2.0. How can I solve this problem without using ArrayList?