No Array slices! What is this?

Discussion in 'Java' started by Alex Polite, Jun 6, 2004.

  1. Alex Polite

    Alex Polite Guest

    Hi

    It's the python to java convert again.

    Google brings me more horrible news.

    Java doesn't support array slices like python.

    Can this be possible?

    alex

    --
    Alex Polite
    http://polite.se
     
    Alex Polite, Jun 6, 2004
    #1
    1. Advertising

  2. Alex Polite

    Filip Larsen Guest

    Alex Polite wrote

    > It's the python to java convert again.
    > Google brings me more horrible news.
    > Java doesn't support array slices like python.


    I do not know python, but perhaps you can use java.util.List.subList.


    Regards,
    --
    Filip Larsen
     
    Filip Larsen, Jun 6, 2004
    #2
    1. Advertising

  3. Alex Polite wrote:
    > Hi
    >
    > It's the python to java convert again.
    >
    > Google brings me more horrible news.
    >
    > Java doesn't support array slices like python.
    >
    > Can this be possible?
    >
    > alex
    >

    Sad, innit?
    java.util.List has a sublist() method, but for arrays, you will have to
    do it the hard way.

    It may be worth writing a utility array slicer for int and String arrays
    if you use arrays a lot. Most of the time, you should be using List and
    family instead.

    Steve
     
    Steve Horsley, Jun 6, 2004
    #3
  4. Alex Polite wrote:

    > Google brings me more horrible news.
    >
    > Java doesn't support array slices like python.


    Neither does C. I don't know about C++, but I'd guess from its heritage
    that it doesn't either. Nor did Fortran 77 and earlier, although
    Fortran 90 and later have very powerful array manipulation features,
    including slicing (that may or may not be "like [P]ython['s]"). Array
    slicing is by no means a must-have feature in any language I've ever
    known about or used.

    Java is a different language than Python. Different languages have
    different features. Sometimes that means that different languages imply
    or benefit from different idioms for similar tasks. It is a serious
    mistake to depend too heavily on "this is how it's done in language <X>"
    when writing in language <Y>.


    John Bollinger
     
    John C. Bollinger, Jun 7, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. proudfeet

    array slices

    proudfeet, Oct 1, 2003, in forum: VHDL
    Replies:
    1
    Views:
    632
    Egbert Molenkamp
    Oct 1, 2003
  2. Replies:
    8
    Views:
    24,502
    Thomas G. Marshall
    May 30, 2005
  3. Patrick Tyler

    string/array slices

    Patrick Tyler, Mar 30, 2011, in forum: Ruby
    Replies:
    12
    Views:
    277
    Adam Prescott
    Mar 31, 2011
  4. drKreso
    Replies:
    5
    Views:
    618
    drKreso
    Jan 5, 2012
  5. TonyShirt

    traversing array slices

    TonyShirt, Feb 27, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    175
    valued customer
    Feb 28, 2004
Loading...

Share This Page