Hirdetés

Keresés

Új hozzászólás Aktív témák

  • shev7
    veterán

    Nézegetem a String osztály metódusait, és találtam valami furcsát.

    substring(start,end)

    Már az is eléggé furcsa, hogy a substring nem ilyen:
    substring(start,darab)

    Na de hogy az ''end'' 1-től számozódik!!!! Ez hihetetlen. Főleg annak tükrében, hogy a ''start'' meg 0-tól. Azért megkérdezném attól, aki ezt így találta ki, hogy mi volt az oka.

    Gondolom, az oka a Java nyelv elődeiben keresendő.
    Direkt megnéztem, C++-ban a substring(start, darab). Utánanéztem az Ada-nak, úgy láttam, az se ilyen ''elvetemült'', a slice-oknál tól-ig lehet megadni a pozíciót.


    hat pedig eleg egyertelmu a mukodese:

    ''Returns a new string that is a substring of this string. The
    substring begins at the specified <code>beginIndex</code> and
    extends to the character at index <code>endIndex - 1</code>.
    Thus the length of the substring is <code>endIndex-beginIndex</code>.''

Új hozzászólás Aktív témák