I'm using retrofit to fetch data from server. I want to get last element from my arrayList, how to do that?
I already read how to get last element from this quetsion How to get the last value of an ArrayList but it won't work.
This is my JSON Object http://ipsta.tech/koor.php
This my adapter class
    private Context context;
    public KinectAdapter(List<Koor> koorList, Context context) {
        this.koorList = Collections.singletonList(koorList);
        this.context = context;
         
        }
    @Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.kinect,parent,false);
        return new ViewHolder(view);
        }
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    holder.x.setText(String.valueOf(koorList.get(position).getX()));
    holder.y.setText(String.valueOf(koorList.get(position).getY()));
}
@Override
public int getItemCount() {
        return koorList.size();
        }
public static class ViewHolder extends RecyclerView.ViewHolder{
    public TextView x,y;
    public ViewHolder(View itemView) {
        super(itemView);
        x = (TextView) itemView.findViewById(R.id.tvX);
        y = (TextView) itemView.findViewById(R.id.tvY);
    }
}
And this is my class
        koorArrayList = new ArrayList<>();
        progressDialog.setTitle("Displaying data");
        progressDialog.setMessage("Loading ...");
        progressDialog.show();
        ApiInterface apiInterface = ApiClient.getApiClient().create(ApiInterface.class);
        Call<List<Koor>> call = apiInterface.getAllDataKoor();
        call.enqueue(new Callback<List<Koor>>() {
            @Override
            public void onResponse(Call<List<Koor>> call, Response<List<Koor>> response) {
                koorArrayList = response.body();
Koor e = koorArrayList.get(koorArrayList.size() - 1);
                    KinectAdapter foodAdapter = new KinectAdapter(e, Kinect.this);
                    recyclerView.setLayoutManager(new LinearLayoutManager(Kinect.this));
                    recyclerView.setItemAnimator(new DefaultItemAnimator());
                    recyclerView.setAdapter(foodAdapter);
                    progressDialog.dismiss();
                }
            @Override
            public void onFailure(Call<List<Koor>> call, Throwable t) {
                Toast.makeText(Kinect.this, t.getMessage(), Toast.LENGTH_SHORT).show();
                progressDialog.dismiss();
            }
this is my Koor class:
public class Koor {
    @SerializedName("x")
    private float x;
    @SerializedName("y")
    private float y;
    public Koor(float x, float y, String time) {
        this.x = x;
        this.y = y;
    }
    public float getX() {
        return x;
    }
    public float getY() {
        return y;
    }
and also my output JSONobject is float type.
Where should i place list.get(list.size()-1; ?
 
     
    