Nice TWiki > Doc > CodeExamples > StrcatBeginnerExample (r1.2) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }
/* Please try the NoviceExamples before the BeginnerExamples
To compile:
   nicec --sourcepath=.. -a strcat.jar strcat
To run:
   java -jar strcat.jar 40000
*/


void main(String[] args){
   var n = toSingleInt(args);
   let s = "hello\n";
   let buffer = new StringBuffer(32);

   while (n-- > 0) buffer.append(s);

   println(buffer.length()); 
}


int toSingleInt(String[] s){
   try { return Integer.parseInt(s[0]); }
   catch (Exception e){ return 1; } }


/* Notes - language
Compare with Java at the "Win32 Language Shootout"

   let buffer = new StringBuffer(32);
Declare and initialize StringBuffer buffer, the compiler will infer 
the type from the initial assignment. Identifiers declared with 
keyword let can be assigned a value only once. 

*/
-- IsaacGouy - 27 Aug 2003

Topic StrcatBeginnerExample . { Edit | Attach | Ref-By | Printable | Diffs | r1.4 | > | r1.3 | > | r1.2 | More }
Revision r1.2 - 27 Aug 2003 - 16:34 GMT - IsaacGouy
Parents: WebHome > CodeExamples
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.

Doc.StrcatBeginnerExample moved from Doc.StrcatNoviceExample on 27 Aug 2003 - 16:32 by IsaacGouy - put it back