Here you can find the source of square(int n)
Parameter | Description |
---|---|
n | a parameter |
public static int square(int n)
//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; } }