Java Square square(int n)

Here you can find the source of square(int n)

Description

Return square of N.

License

Open Source License

Parameter

Parameter Description
n a parameter

Declaration

public static int square(int n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static int[] sqCache = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81,
            100 };/*from   w w  w  .  java 2  s.co  m*/

    /**
     * Return square of N.
     * @param n
     * @return
     */
    public static int square(int n) {
        if (n < sqCache.length) {
            return sqCache[n];
        }
        return n * n;
    }
}

Related

  1. square(double a)
  2. square(double[] in, double[] out)
  3. square(double[][] m)
  4. square(final double num)
  5. square(float number, int power)
  6. square(int value)