I am a freshman at a university in Niigata when I started learning programming. It's a university assignment, but I got an assignment using Java to "create the following method as a public static method". The problem is as follows.
(1) Average
(Method name) heikin
(Argument 1) double [] x
(Return value) double: Mean value of the elements of array x

(2) Inner product
(Method name) naiseki
(Argument 1) double [] x
(Argument 2) double [] y
(Return value) double:
x [0] y [0] + ··· + x [N − 1] y [N − 1]
Where N is the size of the array x.
(Caution) The size of array x and array y may be the same.

(3) Norm
(Method name) norm
(Argument 1) double [] x
(Return value) double:
√ x [0] ^ 2 + ··· + x [N − 1] ^ 2
However, N is the size of the array x.

(4) Root of quadratic equation
(Method name) nijihouteisiki
(Argument 1) double a
(Argument 2) double b
(Argument 3) double c
(Return value) double []: Two solutions of the quadratic equation ax ^ 2 + bx + c = 0
Of −b ± √b ^ 2−4ac/2a, the smaller solution is the 0th element, and the larger solution is the 1st.
Make it an element.
(Caution) a ̸ = 0 may be set. If the roots are not real, you don't have to think about it.

So I investigated this problem myself and wrote it in eclipse as follows.
public class sample21 {
// (1)
public static void main (String [] args) {
double [] x = {0,1,2};
System.out.println (heikin (x));
public static double heikin (double [] x) {
double e = 0.0;
for (double i: x)
{e + = i;
return e/x.length;

// (2)
public static void main1 (String [] args) {
double [] x = {0,1,2};
double [] y = {3,4,5};
System.out.println (naiseki (x, y));
public static double naiseki (double [] x, double [] y) {
double r = 0;
for (int i = 0;i r + = x [i] * y [i];
return r;

// (3)
public static void main2 (String [] args) {
double [] x = {1,2,3};
System.out.println (norm (x));
public static double norm (double [] x) {
double sum = java.util.Arrays.stream (x) .map (y->y * y) .sum ();
return Math.sqrt (sum);

public static void main3 (String [] args) {
try (java.util.Scanner s = new java.util.Scanner (System.in)) {
System.out.print ("a =");
double a = s.nextDouble ();
System.out.print ("b =");
double b = s.nextDouble ();
System.out.print ("c =");
double c = s.nextDouble ();
double [] result = nijihouteisiki (a, b, c);
System.out.printf ("x0 =% f, x1 =% f% n", result [0], result [1]);

public static double [] nijihouteisiki (double a, double b, double c) {
double d = b * b-4 * a * c;
return new double [] {
(-b --Math.sqrt (d))/(2 * a),
(-b + Math.sqrt (d))/(2 * a)};


I want to read all four of these programs, but only the first one is read.
I can't figure out if it's a bug here or if something is missing.
I am sorry that it will take a busy time for young people who are not familiar with such programming, but I would be grateful if you could teach me.
It seems that Karasu is good, but if possible, if anyone knows a simpler method than this, I would appreciate your professor.

When I actually type this into eclipse, no error message occurs, but when I run it as described above, it only reads the first (1) and does not display anything.

What I tried

As mentioned above, I tried to suspect that it was a bug in eclipse, but other programs worked properly, so there seemed to be no bugs at all.
So I asked various people on the net to find out what was missing, corrected the above program and wrote it, but (1) and below do not work at all. Honestly, I'm in a state of obstruction as to where to start. I would like a professor again.

Supplementary information (FW/tool version, etc.)