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 5959153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:38:43+00:00 2026-05-22T18:38:43+00:00

So, I want an array of Vector of Integer in Java. If I put

  • 0

So, I want an array of Vector of Integer in Java.

If I put

Vector<Integer>[] matrix;
matrix = new Vector<Integer>[100];

I get cannot the compilation error

cannot create a generic array of Vector

Should I use

    matrix = new Vector[100];

instead? (which gives a warning)

Or should I simply not use an array of vectors and use vector of vector instead?

Note: I don’t want a Vector< Integer >, I want a Vector< Integer >[] to create a matrix of Integers without using Integer[][].

  • 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-05-22T18:38:43+00:00Added an answer on May 22, 2026 at 6:38 pm

    Java simply doesn’t have any means to create arrays of a parameterized type without getting or suppressing a warning. So the best you can get is this:

    @SuppressWarnings("unchecked")
    Vector<Integer>[] anArray = (Vector<Integer>[]) new Vector<Integer>[100];
    

    You can get around this problem if you avoid arrays entirely. I.e.:

    Vector<Vector<Integer>> list = new Vector<Vector<Integer>>(100);
    

    Or with the collection types:

    List<List<Integer>> list = new ArrayList<List<Integer>>(100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

char *values = 3 1 4 15; vector<int> array; I want to populate the
I want to create an array with a message. $myArray = array('my message'); But
I want to create an array/list of strings of the Comma seperated strings (file
I want to inherit from some kind of array/vector/list class so that I can
Let's make this very easy. What I want: @array = qw/one two one/; my
When I want an array of flags it has typically pained me to use
I have a class that contains an array. I want this array to be
I want to send an array constructed in javascript with the selected values of
I want to shift the contents of an array of bytes by 12-bit to
I want to build two-dimentional array of strings where length of one dimention is

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.