ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        with_gc
      
      
        
          | 
            Last change
 on this file since be151bf was             9c14ae9, checked in by Rob Schluntz <rschlunt@…>, 9 years ago           | 
        
        
          | 
             
add thesis source 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            508 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | class variadic {
 | 
|---|
| 2 |   int sum(int... args) {
 | 
|---|
| 3 |     int s = 0;
 | 
|---|
| 4 |     for (int x : args) {
 | 
|---|
| 5 |       s += x;
 | 
|---|
| 6 |     }
 | 
|---|
| 7 |     print(args.length, " ", args[0], " ", args[args.length-1], "\n");
 | 
|---|
| 8 |     return s;
 | 
|---|
| 9 |   }
 | 
|---|
| 10 | 
 | 
|---|
| 11 |   void print(Object... objs) {
 | 
|---|
| 12 |     for (Object obj : objs) {
 | 
|---|
| 13 |       System.out.print(obj);
 | 
|---|
| 14 |     }
 | 
|---|
| 15 |   }
 | 
|---|
| 16 | 
 | 
|---|
| 17 |   public void run() {
 | 
|---|
| 18 |     print("The sum from 1 to 10 is ", sum(1,2,3,4,5,6,7,8,9,10), ".\n");
 | 
|---|
| 19 |     print(sum(new int[]{1, 2,3}), "\n");
 | 
|---|
| 20 |   }
 | 
|---|
| 21 | 
 | 
|---|
| 22 |   public static void main(String args[]) {
 | 
|---|
| 23 |     new variadic().run();
 | 
|---|
| 24 |   }
 | 
|---|
| 25 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.