-3

This is mylist :

[675463645876543456746347543, 985769854789, 3456435]

I need to have something like below:

System.out.print(mylist.get(1));  ---> 675463645876543456746347543 and it is 27 digits

How can I show the size of every node?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

3 Answers3

2

If you have Strings in your list, you could use length or you could convert int to String and use length but if you have integers and you don't want to convert read this: How can I count the digits in an integer without a string cast?. If you have integers I recommend you the second way.

Community
  • 1
  • 1
jenaiz
  • 547
  • 2
  • 15
0

Also you can just get each value in the list as a String and take the length of the String.

Francis Upton IV
  • 19,322
  • 3
  • 53
  • 57
0

Call toString method of each item and check the length of String.

System.out.print(mylist.get(1).toString().length() );
narek.gevorgyan
  • 4,165
  • 5
  • 32
  • 52