Computer Science Canada

Java 1.5 Beta Surfaces

Author:  wtd [ Mon Feb 09, 2004 11:54 am ]
Post subject:  Java 1.5 Beta Surfaces

http://java.sun.com/developer/technicalArticles/releases/j2se15/

The article describes the changes better than I can. Enjoy.

But I can't resist throwing out an example (astute Java programmers should notice a number of new things):

Java:
import java.lang.*;
import java.util.*;

class Test {
   public static int add(int ... args) {
      int output = 0;
      for (int i : args) output += i;
      return output;
   }
   public static void main(String[] args) {
      System.out.printf("%d\n", add(1, 2, 3, 4));
      ArrayList<Integer> arr = new ArrayList<Integer>();
      arr.add(0, 4);
      arr.add(1, 3);
      for (Integer i : arr) System.out.printf("%d - ", i);
   }
}

Author:  rizzix [ Mon Feb 09, 2004 4:40 pm ]
Post subject: 

yes 1.5 is very exciting!!

i'll be modifying my bot code as soon as the release version of 1.5 is released.

i think the most exciting feature are the variable args, the enhanced for loop and auto-boxing.

Author:  wtd [ Tue Feb 10, 2004 7:44 pm ]
Post subject: 

rizzix wrote:
i think the most exciting feature are the variable args, the enhanced for loop and auto-boxing.


It's all exciting.

You left off generics, which mean no casting... or exceptions related to that. The only thing I'd like from Nice (a language that compiles to JVM bytecode) is the functional side of things, like the ability to create anonymous functions/methods, and and the ability to simplify function syntax.

code:
int add(int a, int b) = a + b;


Of course, then I'd also like the ability to simplify parameters...

code:
-- in Eiffel
feature { ANY }
   add_four_integers(a, b, c, d : INTEGER): INTEGER is
      do
         Result := a + b + c + d
      end


: