How to get quantity of items from an Arraylist?

Asked

Viewed 738 times

3

I’m trying to count how many items there are in one ArrayList, I already have something ready:

private int quantidadeN = listaNotificacaos.size();

It should store the quantity within the variable quantidadeN, but when I play on the page it brings a result 0.

On the page I’m calling with this code:

#{notificacaoControle.quantidadeN}

Can someone help me?

  • Already put a breakpoint to see what the value of listaNotificacaos.size() ?

  • I played right into Front End #{notifiedControl.Notificacoes.size()} and it worked. Thanks.

1 answer

3


The problem is that when the variable quantidadeN was defined, the size() was equal to 0.

Use the collection proopy in your EL:

#{notificacaoControle.listaNotificacoes.size()}
  • It worked, thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.