Quali sono le novita di java 1.5-beta???
Tnk 1000000000000000000000
Quali sono le novita di java 1.5-beta???
Tnk 1000000000000000000000
La stupidità umana e l'universo sono infinite.
Della seconda non sono certo(Einstein)
Gnu/Linux User
da: http://zamples.com/JspExplorer/sampl...lesJDK1_5.html
Autoboxing
Java's distinction between primitive types and their equivalent Object types was painful. Fortunately, with the advent of autoboxing, that will become a fading memory.
// automatically convert one type to another
Integer integer = 1;
System.out.println(integer);
// mix Integer and ints in the same expression
int i = integer + 3;
System.out.println(i);
Collections
The collections framework is greatly enhanced by generics, which allows collections to be typesafe.
LinkedList<String> stringList = new LinkedList<String>();
stringList.add("of");
stringList.add("course");
stringList.add("my");
stringList.add("horse");
Iterator<String> iterator = stringList.iterator();
for (String s : stringList)
System.out.print(s + " ");
Enhanced for loop
int array[] = {1, 2, 3, 4};
int sum = 0;
for (int e : array) // e is short for element; i would be confusing
sum += e;
System.out.println(sum);
Enums
Java programmers rejoice with the availability of enums.
enum Suit { clubs, diamonds, hearts, spades };
for (Suit suit : Suit.values())
System.out.println(suit);
Formatted Output
Developers now have the option of using printf type functionality to generated formatted output. Most of the common C printf formatters are available.
System.out.printf("name count\n");
String user = "fflintstone";
int total = 123;
System.out.printf("%s is %d years old\n", user, total);
E altro,
i template C++ ??Originariamente inviato da anx721
Collections
La stupidità umana e l'universo sono infinite.
Della seconda non sono certo(Einstein)
Gnu/Linux User
Non conosco i templates del c++, ma direi di no, Collection è la radice di una gerarchia di interfacce e classi per rappreesntare liste e insiemi,
in java corrisponde acodice:LinkedList<String> stringList = new LinkedList<String>();
codice:std::list<std::string> stringList;
La stupidità umana e l'universo sono infinite.
Della seconda non sono certo(Einstein)
Gnu/Linux User
Si, ok, ma penso che i templates del c++ siano molto piu generali, nel senso che questa novità di java 1.5 riguarda solo le Collection,Originariamente inviato da Luc@s
in java corrisponde acodice:LinkedList<String> stringList = new LinkedList<String>();
codice:std::list<std::string> stringList;