![]() |
|
|
|||||||
![]() |
Java - How to do Arrays.asList on only part of an Object[] array? |
|
|
Thread Tools | Search this Thread |
|
|
#11 |
|
Christian wrote:
> Lew schrieb: >> So why are you using an obsolete version of Java? >> > > there are people that need their software to work with Mac Os X ... > sadly due to Apple's reluctance in not supporting their older > OS/Architectures we will all be stuck with Java 5 if we want to be > compatible to MacOsX ... > > > so Java 5 even if in EoL will not be obsolete in the next years... The OP made no mention of Mac. I don't routinely expand headers, so the question was a natural one. I thought I'd read that Mac had Java 6 by now. As for not being obsolete, Java 5 is no longer available for free from Sun. -- Lew Lew |
|
|
|
|
#12 |
|
Posts: n/a
|
Lew wrote:
> laredotornado wrote: >> I'm using Java 1.5. > > You have a plethora of answers already, but I'm wondering why you're > using an obsolete version of Java. > So why are you using an obsolete version of Java? How do you know that he is using an obsolete version of Java? SUN's free version EOL'ed October 30. But SUN's business version will first EOL June 2019. I don't even think IBM has announced a EOL date for WAS 6.1 with Java 1.5 yet. I will expect Oracle to support whatever WebLogic versions using Java 1.5 for quite some time. Arne Arne Vajhøj |
|
|
|
#13 |
|
Posts: n/a
|
On Nov 4, 4:25*pm, Tom Anderson <t...@urchin.earth.li> wrote:
> On Wed, 4 Nov 2009, laredotornado wrote: > > As you may know, the Arrays.asList method will return an ArrayList > > object from an Object[] array. *What is the easiest way to achieve this > > when you only want a specific range of that Object[] array, say, its > > first element up until it's length - 1 element? > > Arrays.asList(anArray).subList(startIndex, endIndex); > > Both the array list and the sub-list are lightweight wrappers, so there's > no copying, just two method calls and some arithmetic on each access. > > tom > > -- > That must be one of the best things you can possibly do with a piglet, > booze and a cannon. -- D Forgot to update this thread, but since there was consensus on Tom's solution I tried it out and it worked great. 5 stars, - Dave laredotornado |
|
|
|
#14 |
|
Posts: n/a
|
Lew wrote:
> Christian wrote: >> Lew schrieb: >>> So why are you using an obsolete version of Java? >> >> there are people that need their software to work with Mac Os X ... >> sadly due to Apple's reluctance in not supporting their older >> OS/Architectures we will all be stuck with Java 5 if we want to be >> compatible to MacOsX ... >> >> so Java 5 even if in EoL will not be obsolete in the next years... > > The OP made no mention of Mac. I don't routinely expand headers, so the > question was a natural one. > > I thought I'd read that Mac had Java 6 by now. It has. But only newer versions. For whatever reason Apples does not backport. > As for not being obsolete, Java 5 is no longer available for free from Sun. Support is not available. It is still available for download. Arne Arne Vajhøj |
|
|
|
#15 |
|
Posts: n/a
|
laredotornado wrote:
> On Nov 4, 4:25 pm, Tom Anderson <t...@urchin.earth.li> wrote: >> On Wed, 4 Nov 2009, laredotornado wrote: >>> As you may know, the Arrays.asList method will return an ArrayList >>> object from an Object[] array. What is the easiest way to achieve this >>> when you only want a specific range of that Object[] array, say, its >>> first element up until it's length - 1 element? >> Arrays.asList(anArray).subList(startIndex, endIndex); >> >> Both the array list and the sub-list are lightweight wrappers, so there's >> no copying, just two method calls and some arithmetic on each access. > > Forgot to update this thread, but since there was consensus on Tom's > solution I tried it out and it worked great. 5 stars, - Dave Just note that as Tom wrote then asList and subList does not copy data. Besides meaning good performance it also means that modifications to the list also affects the array. import java.util.Arrays; import java.util.List; public class Backing { public static void main(String[] args) { String[] sa = { "A", "BB", "CCC", "DDDD" }; List<String> sl = Arrays.asList(sa).subList(1, 3); sl.set(0, "BBX"); sl.set(1, "CCCX"); for(String s : sa) { System.out.println(s); } } } outputs: A BBX CCCX DDDD That is fine. You just need to be aware of it. Arne Arne Vajhřj |
|
|
|
#16 |
|
Posts: n/a
|
Lew wrote:
>> As for not being obsolete, Java 5 is no longer available >> for free from Sun. Arne Vajhøj wrote: > Support is not available. > > It is still available for download. Do you have a link for a free download of Java 5 from Sun? -- Lew Lew |
|
|
|
#17 |
|
Posts: n/a
|
Lew wrote:
>>> As for not being obsolete, Java 5 is no longer available for free >>> from Sun. Arne Vajhøj wrote: >> Support is not available. >> >> It is still available for download. Lew wrote: > Do you have a link for a free download of Java 5 from Sun? I finally found it: <http://java.sun.com/javase/downloads/index_jdk5.jsp> -- Lew Lew |
|
|
|
#18 |
|
Posts: n/a
|
Lew wrote:
>>>> As for not being obsolete, Java 5 is no longer available for free >>>> from Sun. Arne Vajhøj wrote: >>> Support is not available. >>> >>> It is still available for download. Lew wrote: >> Do you have a link for a free download of Java 5 from Sun? > > I finally found it: > <http://java.sun.com/javase/downloads/index_jdk5.jsp> And support is available for a fee. <http://www.sun.com/software/javaforbusiness/support.jsp> <http://www.sun.com/software/javaforbusiness/getit_download.jsp> So Sun's definition of "End of Service Life" is a bit loose. -- Lew Lew |
|
|
|
#19 |
|
Posts: n/a
|
Lew wrote:
> Lew wrote: >>>>> As for not being obsolete, Java 5 is no longer available for free >>>>> from Sun. > > Arne Vajhøj wrote: >>>> Support is not available. >>>> >>>> It is still available for download. > > Lew wrote: >>> Do you have a link for a free download of Java 5 from Sun? >> >> I finally found it: >> <http://java.sun.com/javase/downloads/index_jdk5.jsp> > > And support is available for a fee. > <http://www.sun.com/software/javaforbusiness/support.jsp> > <http://www.sun.com/software/javaforbusiness/getit_download.jsp> > > So Sun's definition of "End of Service Life" is a bit loose. Not really. They have a free version that they EOL relative early and a for money version they support a lot longer. It makes sense to me. Arne Arne Vajhøj |
|
|
|
#20 |
|
Posts: n/a
|
Lew wrote:
> Lew wrote: >>>> As for not being obsolete, Java 5 is no longer available for free >>>> from Sun. > > Arne Vajhøj wrote: >>> Support is not available. >>> >>> It is still available for download. > > Lew wrote: >> Do you have a link for a free download of Java 5 from Sun? > > I finally found it: > <http://java.sun.com/javase/downloads/index_jdk5.jsp> You can still download Java 1.1.8 if you want to. http://java.sun.com/products/archive/ Arne Arne Vajhøj |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| No array is defined ... | John Dean | Computer Support | 2 | 03-16-2006 08:02 PM |
| Re: Stop posting politics at alt.culture.alaska | Aratzio | Computer Support | 102 | 11-18-2004 01:26 AM |
| Everytime I try to open OE or IE I get windows installer trying to install office 2003 | cteq1@athotmail.com | Computer Support | 14 | 11-12-2004 09:00 AM |
| Applying an image to a new raid array. | Michael-NC | Computer Information | 1 | 07-21-2004 05:09 AM |
| Ultra ATA 100/133 Controller configuration? | Flippor | Computer Support | 3 | 04-02-2004 05:59 PM |