vm/src/test/java/org/apidesign/vm4brwsr/Array.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 24 Sep 2012 11:07:38 +0200
changeset 22 b9318fe303cd
parent 21 src/test/java/org/apidesign/java4browser/Array.java@d8807b6a636a
child 32 82476405e1ad
permissions -rw-r--r--
Getting ready for multiple projects inside one Hg repository
     1 /*
     2 Java 4 Browser Bytecode Translator
     3 Copyright (C) 2012-2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     4 
     5 This program is free software: you can redistribute it and/or modify
     6 it under the terms of the GNU General Public License as published by
     7 the Free Software Foundation, version 2 of the License.
     8 
     9 This program is distributed in the hope that it will be useful,
    10 but WITHOUT ANY WARRANTY; without even the implied warranty of
    11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12 GNU General Public License for more details.
    13 
    14 You should have received a copy of the GNU General Public License
    15 along with this program. Look for COPYING file in the top folder.
    16 If not, see http://opensource.org/licenses/GPL-2.0.
    17 */
    18 package org.apidesign.vm4brwsr;
    19 
    20 /**
    21  *
    22  * @author Jaroslav Tulach <jtulach@netbeans.org>
    23  */
    24 public class Array {
    25     byte[] bytes = { 1 };
    26     short[] shorts = { 2, 3 };
    27     int[] ints = { 4, 5, 6 };
    28     float[] floats = { 7, 8, 9, 10 };
    29     double[][] doubles = { {11}, {12}, {13}, {14}, {15} };
    30     char[] chars = { 'a', 'b' };
    31     
    32     private Array() {
    33     }
    34     
    35     byte bytes() {
    36         return bytes[0];
    37     }
    38     short shorts() {
    39         return shorts[1];
    40     }
    41     
    42     int ints() {
    43         return ints[2];
    44     }
    45     
    46     float floats() {
    47         return floats[3];
    48     }
    49     
    50     double doubles() {
    51         return doubles[4][0];
    52     }
    53     
    54     private static final Array[] ARR = { new Array(), new Array(), new Array() };
    55     
    56     public static double sum() {
    57         double sum = 0.0;
    58         for (int i = 0; i < ARR.length; i++) {
    59             sum += ARR[i].bytes();
    60             sum += ARR[i].shorts();
    61             sum += ARR[i].ints();
    62             sum += ARR[i].floats();
    63             sum += ARR[i].doubles();
    64         }
    65         return sum;
    66     }
    67     public static int simple() {
    68         int[] arr = { 0, 1, 2, 3, 4, 5 };
    69         
    70         int sum = 0;
    71         for (int i = 0; i < arr.length; i++) {
    72             sum += arr[i];
    73         }
    74         return sum;
    75     }
    76 }