Ad
  • Default User Avatar

    concatenation of an int to a string coerces to a string

  • Default User Avatar

    Can someone explain why this would work?
    didnt they want the answer in string format?

  • Custom User Avatar

    I didnt know that we can initialize variables while calling function. Thanks !!!

  • Custom User Avatar

    Thank you 🙂 The "IntStream.iterare(int seed, IntUnaryOperator operator)" returns an infinite sequential ordered IntStream produced by iterative application of the provided IntUnaryOperator. The seed is the initial element of the iteration.
    So basically, it created an infinite stream, starting with the seed, using the IntUnaryOperator operation (+1,-5,etc.) on each element i, to create this infinite sequential stream. The limit is to cancel the 'infinite' part, otherwise it'd be an infinite loop. Then it gets converted to an array.

  • Custom User Avatar

    This is a cool, solution. I am guessing i becomes n, and the iterate method returns the iterator, so it runs once and then adds the number to the array?