Link to home
Start Free TrialLog in
Avatar of heyhey84
heyhey84

asked on

Dimensional Array

How to create sub array with different length?

[0] - > [0]
[1] -> [0] [1]
[2] -> [0] [1] [2]
[3] -> [0] [1] [2] [3]
ASKER CERTIFIED SOLUTION
Avatar of gkishoreji
gkishoreji

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of heyhey84
heyhey84

ASKER

After able created my sub array with different length
The initial one dimension array will be all null

if i want to insert a value

Insert value 1
[0] -> [value 1]
[1] -> null
[2] -> null
[3] -> null

Insert value 2
[0] -> [Value 2]
[1] -> [Value 1][]
[2] -> null
[3] -> null

How do i create this insertion of value? bigger value to be store on top
void insert(int n) {
          
          // i think this should create the correct size of array
        count = count + 1;
          a[count] = new int[count+1];
          
        // how to insert the value into the correct slot?                    
       
    }
thanks