The Artima Developer Community
Sponsored Link

Java Answers Forum
converting vector to array

1 reply on 1 page. Most recent reply: Mar 6, 2002 1:17 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
jayakumar perumal

Posts: 16
Nickname: jai
Registered: Feb, 2002

converting vector to array Posted: Mar 6, 2002 1:19 AM
Reply to this message Reply
Advertisement
can anyone help me how to convert a vector to integer array.also how to draw color fringes for an image
thanx
jai


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: converting vector to array Posted: Mar 6, 2002 1:17 PM
Reply to this message Reply
If you mean converting a Vector to an Integer object array, then you can simply use the toArray() method. If you want an array of int, then I think you have to do it yourself, but it would be pretty straight forward:
    static int [] vectorToIntArray( Vector v )
    {
        int [] array = new int[v.size()];
        Iterator it = v.iterator();
        for( int i = 0; it.hasNext(); i++ )
        {
            try
            {
                array[i] = ((Integer)it.next()).intValue();
            }
            catch( ClassCastException cce )
            {
                array[i] = 0;
            }
        }
        return array;
    }

Flat View: This topic has 1 reply on 1 page
Topic: java.lang.process.exec() and I/O. Previous Topic   Next Topic Topic: sorting arrays

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use