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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:16:11+00:00 2026-05-25T17:16:11+00:00

How do I implement the following data ? somelisttype <int>obj ; obj 0,0 =>

  • 0

How do I implement the following data ?

somelisttype <int>obj ;

obj 0,0 => val0
obj 0,1 => val1
obj 0,2 => val2
obj 1,0 => val8
obj 2,0 => val9
obj 2,1 => val10

0,0 ; 0,1 are the keys ( or in other way the row index or column index.)

I would like to have following functionality ..

obj 0.add(val11) == obj 0,3 => val11
obj 3.add(val12) == obj 3,0 => val12

obj 2.length => 2
obj 3.length => 1

obj 0,2 => val2

ValXX => are values and not objects ( would be integers )

I don’t want to create 2d array since I don’t know length of total obj or individual obj0,obj1

What variable type can be used for this in android ??

  • 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-25T17:16:12+00:00Added an answer on May 25, 2026 at 5:16 pm

    What’s about List<List<Integer>>?

    You can’t avoid the generic type to be an object here but since cast from Integer to int is implicit you would see any difference in use.

    Update

    Okay here it is:

    MyList l = new MyList();
    l.set(0, 0, 1);
    l.set(1, 0, 2);
    l.set(1, 1, 3);
    
    Log.d("TAG", l.get(0, 0) + " " + l.get(1, 0) + " " + l.get(1, 1));
    

    Here the implementation (o course you have to make sure that used index is right, so you can’t add index 1 when 0 is not already set):

    class MyList {
    
        private List<List<Integer>> mList = new ArrayList<List<Integer>>();
    
        public void set(int i, int k, int value) {
            List<Integer> list;
    
            if (i == mList.size()) {
                list = new ArrayList<Integer>();
                mList.add(i, list);
            } else {
                list = mList.get(i);
            }
    
            if (k == list.size()) {
                list.add(value);
            } else {
                list.set(k, value);
            }
        }
    
        public int get(int i, int k) {
            return mList.get(i).get(k);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following this how-to to implement Core Data storage in my app: I have
How can I implement the following in python? #include <iostream> int main() { std::string
we need to implement the following query in such a way that we should
I am trying to implement the following functionality: Flex data grid has 1 default
I'm trying to figure out the best way to represent the following data structures
I'm looking for a Collection type data structure to implement the following. Say I
What is the best way to implement the following scenario in Java: A sort
I'd like to implement the following data structure in c++ (pseudo code): Map<Integer, Integer>
I want to implement the following constraints in mysql: create table TypeMapping( ... constraint
I'm trying to implement the following mod_rewrite rule: host.com/developer/ => host.com/developer/index.py host.com/developer/branchX => host.com/developer/index.py?branch=branchX

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.