Guest User

Untitled

a guest
Oct 18th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. Object[] array = { ... };
  2. System.out.println(array.length);
  3.  
  4. Object[][] array = { ... };
  5. int count = Stream.of(array).mapToInt(m -> m.length).sum();
  6. System.out.println(count);
  7.  
  8. public static int count(Object[][] array) {
  9. int result = 0;
  10. for (Object[] m : array) {
  11. result += m.length;
  12. }
  13. return result;
  14. }
  15.  
  16. String s = "...";
  17. System.out.println(s.length());
  18.  
  19. Set<Integer> s = new TreeSet<Integer>();
  20. s.add(...);
  21. System.out.println(s.size());
  22.  
  23. public class ExampleArrayLenght {
  24. public static void main(String[] args) {
  25. String[] arrays = {"one", "two", "three"};
  26. int arrayLength = arrays.length;
  27. System.out.println("Длинна массива = " + arrayLength + " элемента.");
  28. }
  29. }
  30.  
  31. int[] array = {1, -4, 3, 5};
  32. int length = array.length;
  33.  
  34. public int countArr(List<Integer> arr){
  35. return (int) arr.stream().count();
  36. }
Add Comment
Please, Sign In to add comment