jaroslav@21: /* jaroslav@21: Java 4 Browser Bytecode Translator jaroslav@21: Copyright (C) 2012-2012 Jaroslav Tulach jaroslav@21: jaroslav@21: This program is free software: you can redistribute it and/or modify jaroslav@21: it under the terms of the GNU General Public License as published by jaroslav@21: the Free Software Foundation, version 2 of the License. jaroslav@21: jaroslav@21: This program is distributed in the hope that it will be useful, jaroslav@21: but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@21: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@21: GNU General Public License for more details. jaroslav@21: jaroslav@21: You should have received a copy of the GNU General Public License jaroslav@21: along with this program. Look for COPYING file in the top folder. jaroslav@21: If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@21: */ jaroslav@22: package org.apidesign.vm4brwsr; jaroslav@21: jaroslav@21: /** jaroslav@21: * jaroslav@21: * @author Jaroslav Tulach jaroslav@21: */ jaroslav@21: public class Array { jaroslav@21: byte[] bytes = { 1 }; jaroslav@21: short[] shorts = { 2, 3 }; jaroslav@21: int[] ints = { 4, 5, 6 }; jaroslav@21: float[] floats = { 7, 8, 9, 10 }; jaroslav@21: double[][] doubles = { {11}, {12}, {13}, {14}, {15} }; jaroslav@21: char[] chars = { 'a', 'b' }; jaroslav@21: jaroslav@21: private Array() { jaroslav@21: } jaroslav@21: jaroslav@21: byte bytes() { jaroslav@21: return bytes[0]; jaroslav@21: } jaroslav@21: short shorts() { jaroslav@21: return shorts[1]; jaroslav@21: } jaroslav@21: jaroslav@21: int ints() { jaroslav@21: return ints[2]; jaroslav@21: } jaroslav@21: jaroslav@21: float floats() { jaroslav@21: return floats[3]; jaroslav@21: } jaroslav@21: jaroslav@21: double doubles() { jaroslav@21: return doubles[4][0]; jaroslav@21: } jaroslav@21: jaroslav@21: private static final Array[] ARR = { new Array(), new Array(), new Array() }; jaroslav@21: jaroslav@21: public static double sum() { jaroslav@21: double sum = 0.0; jaroslav@21: for (int i = 0; i < ARR.length; i++) { jaroslav@21: sum += ARR[i].bytes(); jaroslav@21: sum += ARR[i].shorts(); jaroslav@21: sum += ARR[i].ints(); jaroslav@21: sum += ARR[i].floats(); jaroslav@21: sum += ARR[i].doubles(); jaroslav@21: } jaroslav@21: return sum; jaroslav@21: } jaroslav@21: public static int simple() { jaroslav@21: int[] arr = { 0, 1, 2, 3, 4, 5 }; jaroslav@21: jaroslav@21: int sum = 0; jaroslav@21: for (int i = 0; i < arr.length; i++) { jaroslav@21: sum += arr[i]; jaroslav@21: } jaroslav@21: return sum; jaroslav@21: } jaroslav@21: }