Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

ArrayList vs. Vector - which is better for webapps?

I've always thought that it's best to use Vectors in Beans or ActionForms because they are synchronized. However, everytime I write one, I get the feeling that I might as well just use an ArrayList. What do you think? The different between the two is that an ArrayList is unsynchronized (seems strange to me since the it does implement Synchronized - the JavaDocs don't lie do they?). It is easy enough to create a synchronized ArrayList using the following code:

Collections.synchronizedList(new ArrayList());

I like ArrayList better, and I'd like to use it - should I just synchronize it on creation, or use Vectors?

Posted in Java at Jan 02 2003, 08:53:58 AM MST 13 Comments
Comments:

Use ArrayList and synchronize (but only as needed). There is a big advantage to using Collections objects everywhere--you can often have functions return Collection and not need to know that your implementation is ArrayList--so that later you can substitute some other kind of Collection as the implementation and not affect the calling code. Also, you probably won't need synchronization in most cases. Any Collection that is request-scoped will be accessed single-threaded (unless you are creating Threads as part of the request). You might only need to synchronize session-scoped collections, of which there should be few, if any.

Posted by Dennis Doubleday on January 02, 2003 at 05:55 PM MST #

I always thought much like the poster above that the ArrayList implementation is the way to go. It seems to be the best Collections implmentation for what you want to do. I was told awhile back Vector sucked and was only still in there for backwards compatablity. I think you should only have to worry about synchronization for shared scope variables (ie application and session variables). --Kurt

Posted by Kurt Wiersma on January 02, 2003 at 06:55 PM MST #

The java.util.ArrayList class doesn't implement "Synchronized", in fact there is no such interface in the standard edition of the Java 2 platform. Synchronization is achieved through enclosing code accessing shared data in <code>synchronized</code> blocks or adding a <code>synchronized</code> identifier to an entire method. When such code is executed it locks the object for which the <code>this</code> reference is valid preventing other threads from modifying the object's state. Synchronization refers to synchronizing several threads' access to such object state. Thanks for your weblog, it's useful, lively and interesting.

Posted by Paul Yunusov on January 03, 2003 at 12:45 AM MST #

You might also check out the FastArrayList in the Jakarta Commons Collections package.

Posted by Brad Smith on January 04, 2003 at 03:58 PM MST #

Posted by 164.164.160.187 on February 10, 2005 at 10:54 AM MST #

i have developed a shopping cart with the help of arraylist.practically it is working properly.

Posted by Rajesh Kumar on December 28, 2005 at 01:29 PM MST #

mkl/

Posted by 220.225.142.21 on December 29, 2005 at 10:51 AM MST #

g

Posted by 203.99.195.2 on May 04, 2006 at 07:29 AM MDT #

zxcC

Posted by 59.144.1.220 on July 03, 2006 at 12:45 PM MDT #

The arraylist seems to be a better choice . I have used these in business application. If we need to synchronize certain part of the code, it is always better to put under synchronized code block or method. If my code need synchronization I will better make my code in such a way that arraylist will be used and they will be inside some wrapper function.

Thanks to java .. There are too much alternatives ways than any other programming. AND BTW keep it simple for maintainence

Posted by kapil on December 16, 2008 at 03:32 AM MST #

The arraylist seems to be a better choice . I have used these in business application. If we need to synchronize certain part of the code, it is always better to put under synchronized code block or method. If my code need synchronization I will better make my code in such a way that arraylist will be used and they will be inside some wrapper function.

Thanks to java .. There are too much alternative ways than any other programming. AND BTW keep it simple for maintainence

Posted by kapil on December 16, 2008 at 03:33 AM MST #

The arraylist seems to be a better choice . I have used these in business application. If we need to synchronize certain part of the code, it is always better to put under synchronized code block or method. If my code need synchronization I will better make my code in such a way that arraylist will be used and they will be inside some wrapper function.

Thanks to java .. There are too much alternative ways than any other programming. AND BTW keep it simple for maintainence

Posted by kapil on December 16, 2008 at 03:33 AM MST #

sorry for multiple posts .. every time i clicked 500 internal error was coming.. I thought my comments are not published.. plz delete my same comments

Posted by kapil on December 16, 2008 at 03:36 AM MST #

Post a Comment:
  • HTML Syntax: Allowed