0

We have array like this

[
    [6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja], 
    [06:06:20, 06:15:25, 2015-03-24, Tuesday, rahu], 
    [06:15:25, 06:23:30, 2015-03-24, Tuesday, guru],
    [06:23:30, 06:33:05, 2015-03-24, Tuesday, shani], 
    [06:33:05, 06:41:40, 2015-03-24, Tuesday, budha], 
    [06:41:40, 06:45:12, 2015-03-24, Tuesday, kethu],
    [06:45:12, 06:55:18, 2015-03-24, Tuesday, shukra]
]

When we print array upsublist.get(o); Output come like this [6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja]

We need get only one value like kuja or rahu or guru .Please tell me .How to get Only one value

We tried like this upsublist.get(o).get(4) We got like this enter image description here

1 Answer 1

1

If [6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja] is an array and it's length is always 5, you can simply write upsublist.get(o)[4] to get the last element. If it's an ArrayList, you can write upsublist.get(o).get(4).

If the length is not fixed, you have to find the index of the last element - upsublist.get(o)[upsublist.get(o).length - 1].

Sign up to request clarification or add additional context in comments.

14 Comments

we not get We tried like this upsublist.get(o).get(4)
We create array like this ArrayList upsublist = new ArrayList(); Please help me
@PavanAlapati What's the type of the inner list? Is it an ArrayList? What happens when you try upsublist.get(o).get(4)?
@PavanAlapati But what is the type of the elements you add to upsublist ?
innerList is List. ArrayList upsublist = new ArrayList();List sublistup = new ArrayList();
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.