Question: Java programming. Critique code on how it can be better. static double calcAverage(ArrayList obj) { Integer count = 0; for (int i=0; i < obj.size();

Java programming. Critique code on how it can be better. 

static double calcAverage(ArrayList obj) { Integer count = 0; for (int i=0;

static double calcAverage(ArrayList obj) { Integer count = 0; for (int i=0; i < obj.size(); i++) { count+=obj.get(i); } } return count/obj.size(); public static void main(String[] args) { ArrayList list1=new ArrayList (); list1.add(10); list1.add(30); System.out.println(calcAverage(list1)); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!