Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:12:01+00:00 2026-06-15T00:12:01+00:00

I have written following java code: public static void main(String[] args) { Vector vector

  • 0

I have written following java code:

public static void main(String[] args) {
    Vector vector = new Vector();
    for(int i=1; i<=10; i++)
        vector.addElement(i);

    Enumeration vEnum = vector.elements();
    while(vEnum.hasMoreElements())
        System.out.println(vEnum.nextElement());
}

While compiling it getting following warning message:

Note: TestJavaApplication.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

And Netbeans complaining with a message of “Obsolete Collection”.

What do you recommend me in this situation?

Note, that I need to use Vector in J2ME application as a dynamic array that stores the order of the elements. I would be happy using Hashtable but unfortunately it doesn’t store the order of its elements.

EDIT 1
After reviewing this answer I changed the declaration from Vector vector = new Vector(); into Vector<String> vector = new Vector<String>();. And now getting another warning message:

TestJavaApplication.java:2: warning: com.sun.org.apache.xerces.internal.parsers.IntegratedParserConfiguration is Sun proprietary API and may be removed in a future release
import com.sun.org.apache.xerces.internal.parsers.IntegratedParserConfiguration;
                                                 ^

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:12:02+00:00Added an answer on June 15, 2026 at 12:12 am

    The warning you are seeing about “unchecked or unsafe operations” is because Vector is a parameterized type. It’s actually Vector<E>, and you should be providing a type argument when you use Vector. If you use a “raw” Vector then you do not get any of the advantages of Java’s generics framework. The “unsafe” warning means that you are missing out on some type safety.

    The “obsolete type” warning is there because Vector has been (essentially) deprecated in favor of List and its implementations (ArrayList and LinkedList, among others).

    The various List types are the general-purpose replacements for Vector. ArrayList can be used as a more-or-less drop-in replacement for Vector, but there are a few differences that you should be aware of. Read the javadocs for more information.

    The most important difference is that Vector is thread-safe but ArrayList and LinkedList are not. If you are relying on Vectors built-in thread safety then you should take a look at the Collections.synchronizedList method.

    EDIT: Oh, you’re using JavaME. You’re probably stuck with Vector in that case. Nevertheless, the generic type warning still applies.

    You can ignore the warnings if you wish. They’re there to tell you that there might be a problem if you’re not careful, but if you are careful then you’ll be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have written the following code class Program { static void Main(string[] args) {
I have the following code: public class Tests { public static void main(String[] args)
I have written the following mergesort code. public class mergesort { public static int
I have written following code for getting location name : UseGpsActivity.java public class UseGpsActivity
I am new to java and i have written the following: package mypackage; public
I've occasionally written Java code in the following manner: public static TrustManager[] getTrustManagers(TruststoreParams tsParams)
I have written the following code, CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(@C:\Users\XXX\Desktop\Backup1\Project\ReportsFolder\ReportSalesInvoice.rpt); Report works
I have the following Java code: import java.util.Arrays; import java.util.Collections; public class Test {
I have written following code to get location name package demo.gps.locname; import java.io.IOException; import
I have written the following code: import java.util.Calendar; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; class Voter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.