jaroslav@106: /** jaroslav@106: * Back 2 Browser Bytecode Translator jaroslav@106: * Copyright (C) 2012 Jaroslav Tulach jaroslav@106: * jaroslav@106: * This program is free software: you can redistribute it and/or modify jaroslav@106: * it under the terms of the GNU General Public License as published by jaroslav@106: * the Free Software Foundation, version 2 of the License. jaroslav@106: * jaroslav@106: * This program is distributed in the hope that it will be useful, jaroslav@106: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@106: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@106: * GNU General Public License for more details. jaroslav@106: * jaroslav@106: * You should have received a copy of the GNU General Public License jaroslav@106: * along with this program. Look for COPYING file in the top folder. jaroslav@106: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@106: */ jaroslav@34: package org.apidesign.vm4brwsr; jaroslav@34: jaroslav@34: /** jaroslav@34: * jaroslav@34: * @author Jaroslav Tulach jaroslav@34: */ jaroslav@34: public class StringSample { jaroslav@34: public static final String HELLO = "Hello World!"; jaroslav@36: private static int counter; jaroslav@36: jaroslav@36: private final int cnt; jaroslav@36: public StringSample() { jaroslav@36: cnt = ++counter; jaroslav@36: } jaroslav@36: jaroslav@34: jaroslav@34: public static char sayHello(int indx) { jaroslav@34: return HELLO.charAt(indx); jaroslav@34: } jaroslav@36: jaroslav@45: public static String fromChars(char a, char b, char c) { jaroslav@45: char[] arr = { a, b, c }; jaroslav@45: return new String(arr).toString(); jaroslav@45: } jaroslav@45: jaroslav@36: public static String toStringTest(int howMuch) { jaroslav@104: counter = 0; jaroslav@36: StringSample ss = null; jaroslav@36: for (int i = 0; i < howMuch; i++) { jaroslav@36: ss = new StringSample(); jaroslav@36: } jaroslav@93: return ss.toString().toString(); jaroslav@36: } jaroslav@104: jaroslav@104: public static String concatStrings() { jaroslav@104: return (toStringTest(1) + "Ahoj").toString(); jaroslav@104: } jaroslav@36: jaroslav@36: @Override jaroslav@36: public String toString() { jaroslav@36: return HELLO + cnt; jaroslav@36: } jaroslav@34: }