julia_v_iluhina

Untitled

Oct 7th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. public class LazyCollectionNthElement extends AbstractLazyElement {
  2.  
  3.     @Override
  4.     public String toString() {
  5.         return "parentCollection[" + index + "] = ";
  6.     }
  7. /*
  8.     не)
  9.     ты не поняла)
  10.  
  11.     в toString() этого элемента - мы используем toString() родительской коллекции
  12.     и индекс
  13.  
  14.     т е
  15.     parentCollection.toString() + "[" + index + "]"
  16. */
  17. ***********************************
  18. return Helpers.getTexts(elements).toArray(new String[elements.size()]);
  19.  
  20. /*
  21.     да, можно так
  22.  
  23.     а можно и проще
  24.  
  25.     http://stackoverflow.com/questions/5374311/convert-arrayliststring-to-string-array
  26.  
  27.         What is happening is that stock_list.toArray() is creating an Object[] rather than a String[] and hence the typecast is failing.
  28.  
  29.         The correct code would be:
  30.  
  31.           String [] stockArr = stockList.toArray(new String[stockList.size()]);
  32.         or even
  33.  
  34.           String [] stockArr = stockList.toArray(new String[0]);
  35.         For more details, refer to the javadocs for the two overloads of List.toArray.
  36.  
  37.         (From a technical perspective, the reason for this API behaviour / design is that
  38.         an implementation of the List<T>.toArray() method has no information of what the <T> is at runtime.
  39.         All it knows is that the raw element type is Object.
  40.         By contrast, in the other case, the array parameter gives the base type of the array.
  41.         (If the supplied array is big enough, it is used. Otherwise a new array of the same type and a larger size
  42.         will be allocated and returned as the result.)
  43.  
  44.  
  45.     http://javadevnotes.com/java-list-to-array-examples
  46. */
  47. ******************************
  48. public interface DescribesEntity<T> {
  49.     String identity();
  50.  
  51. }
  52. /*
  53.     не надо тут дженериков)
  54.     убирай <T>
  55. */
  56. *************************
  57. public class MyFrameworkTest extends BaseTest {
  58. /*
  59.     ну, тест-метод в этом классе сложно назать тестом)
  60.  
  61.     предлагаю просто прибить класс)
  62.  
  63.     посмотрели как работает - и ок
  64. */
Advertisement
Add Comment
Please, Sign In to add comment