I'm working on learning some basic java programming. I have a project that I've been working on dealing mostly with arrays. I have completed the objective, I'm just not sure that I did it in the most effective way possible. My question here is to see if an experienced java programmer wants to take a crack at it so I can compare the coding.

I will include a link to the description of the project. Mind that I am not a student in this class, merely using the guidelines to learn the java language.

Description:
http://cs.boisestate.edu/~mstuart/assignments/14/index.html

I would love any feedback I can get. Thanks!

Dani AI

Generated

has the right idea using the class assignment to practice arrays, and is correct to ask for the code sample (DaniWeb review policy). Useful ways to judge "effectiveness" are: correctness, clarity, robustness against edge cases, and maintainability. Short, single-purpose methods and clear names usually improve all four.

A few practical refactor ideas and a small pattern for handling input when the final size isn’t known:

  • Split responsibilities: readValues, processValues, printResults. Small methods are easier to test.
  • Prefer descriptive names and final constants instead of magic numbers.
  • Handle edge cases: zero-length arrays, divide-by-zero when computing averages, and index-out-of-bounds.
  • If the assignment allows collections, ArrayList<Integer> simplifies resizing. If arrays are required, grow with Arrays.copyOf and keep an explicit size counter.

Example pattern for dynamic growth and final processing:

int[] buf = new int[8];
int size = 0;

// append a value
if (size == buf.length) buf = Arrays.copyOf(buf, buf.length * 2);
buf[size++] = value;

// finalize and compute stats
int[] data = Arrays.copyOf(buf, size);
Arrays.sort(data);
int sum = 0;
for (int v : data) sum += v;
double avg = (double) sum / data.length;
int max = data[data.length - 1];

Debugging/troubleshooting tips: print trimmed state with Arrays.toString(Arrays.copyOf(buf, size)), add simple assertions for invariants, and write a couple of unit tests for boundary cases (empty input, single element, duplicates). If performance matters, avoid boxing (use int[]) and prefer System.arraycopy or Arrays.copyOf to manual element copies.

To make review useful (and to satisfy ): include a minimal, complete example (a main that builds input, expected output, JDK version), and point out any lines the author doubts.

I have completed the objective

Show us the proof (its DaniWeb's policy) and we'll be more than happy to comment on effectiveness and the rest...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.