i have the json data like below
[
{
"user": "sam",
"comment": "jjjjjj",
},
{
"user": "vishnu",
"comment": "hello",
},
{
"user": "ijas",
"comment": "hello bachanji ",
},
{
"user": "kiran",
"comment": "bye",
}
]
i display all the data in recycle view using adapter, actualy i want to display the first two data that is
{
"user": "sam",
"comment": "jjjjjj",
}
{
"user": "vishnu",
"comment": "hello",
}
i fetch data using the below code
List<Data> data=new ArrayList<>();
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
Data current= new Data();
current.user=json_data.getString("user");
current.comment= json_data.getString("comment");
data.add(current);
how can display the first two data