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

  • Home
  • SEARCH
  • 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 9236517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:18:43+00:00 2026-06-18T07:18:43+00:00

So, I completed a project with ease in C++, only to realize I was

  • 0

So, I completed a project with ease in C++, only to realize I was supposed to write it in Java. This wouldn’t be too big of a deal, except that my code uses multidimensional vectors, like:

vector <vector<int> > arr  

Is there something equivalent in Java that would give the same result without having to drastically rewrite the program?

Here’s the code snippet from the C++ program that I am having trouble translating:

vector <vector <int> > arr;

cin >> n;

while (n > 0)
{
    vector <int> row;
    int u;

    for (int i = 0; i < n ; ++i)
    {
        cin >> u;
        row.push_back(u);
    }

    arr.push_back(row);

    n = comb(row.size(), k);
    k++;
}

for (int i = 0; i < arr.size(); i+=2)
    for (int j = 0; j < arr[i].size(); ++j)
        sum += arr[i][j];

for (int i = 1; i < arr.size(); i+=2)
    for (int j = 0; j < arr[i].size(); ++j)
        diff += arr[i][j];
  • 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-18T07:18:44+00:00Added an answer on June 18, 2026 at 7:18 am

    The ArrayList should provide the functionality that you need, if you declare it as an ArrayList<ArrayList<Integer>>. Your calls to push_back() are equivalent to calls to add(). You will lose the array index access notation, but this can be resolved by chaining calls to get().

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

Sidebar

Related Questions

I've currently completed one of two phases of a project that required I write
I've recently completed a project in Java,and showed it to my advisor. Forget about
I have completed a simple database for a project. Only 6tables. Of the 6,
I've just completed an automation script that: downloads a project build to local storage
i am working in a apache web application. i completed a project with this
In my just-completed project, I was working getting distributed transactions working. We implemented this
I've almost completed my project but just have this last thing which I've been
In a project I completed several months I had this in the controller: public
In a recent project I have nearly completed we used an architecture that as
We have just completed implementing a successful but problematic project. We want to get

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.