No Array slices! What is this?

A

Alex Polite

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
 
F

Filip Larsen

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,
 
S

Steve Horsley

Alex said:
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
 
J

John C. Bollinger

Alex said:
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
(e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top