Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [OT]java 1.5-beta novita

    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

  2. #2
    Utente di HTML.it L'avatar di anx721
    Registrato dal
    Apr 2003
    Messaggi
    2,352
    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,


  3. #3
    Originariamente inviato da anx721



    Collections
    i template C++ ??
    La stupidità umana e l'universo sono infinite.
    Della seconda non sono certo(Einstein)

    Gnu/Linux User

  4. #4
    Utente di HTML.it L'avatar di anx721
    Registrato dal
    Apr 2003
    Messaggi
    2,352
    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,


  5. #5
    codice:
    LinkedList<String> stringList = new LinkedList<String>();
    in java corrisponde a
    codice:
    std::list<std::string> stringList;
    La stupidità umana e l'universo sono infinite.
    Della seconda non sono certo(Einstein)

    Gnu/Linux User

  6. #6
    Utente di HTML.it L'avatar di anx721
    Registrato dal
    Apr 2003
    Messaggi
    2,352
    Originariamente inviato da Luc@s
    codice:
    LinkedList<String> stringList = new LinkedList<String>();
    in java corrisponde a
    codice:
    std::list<std::string> stringList;
    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,


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.