title: Is it possible to replace Integer[] with int[]?
body: <p>I'm trying to rewrite my code for a little bit. Is it possible to use <code>int[]</code> array instead of <code>Integer[]</code> in my code?</p>
  
  <p>When I replacing all of <code>Integer[]</code> with <code>int[]</code>, I'm stuck in part of replacing:</p>
  
  <pre class="lang-java prettyprint-override"><code>.toArray(Integer[]::new);
  </code></pre>
  
  <p>with</p>
  
  <pre class="lang-java prettyprint-override"><code>.toArray(int[]::new);
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>public class Main {
  
      private static final int MODULO = (int) (Math.pow(10, 9) + 7);
  
      private static int modulate(final long result) {
          return (int) (result % MODULO);
      }
  
      //private static
  
      private static Integer[] steps(final int smaller, final int larger) {
          final int lcm = lowestCommonMultiple(smaller, larger);
          final int max = lcm / smaller;
          final int min = lcm / larger;
          final Integer[] result = new Integer[max * 2];
  
          int pos = 0;
          for (int i = 1; i &lt;= max; i++) {
              result[pos++] = (i * smaller);
              if (i &lt;= min) {
                  result[pos++] = (i * larger);
              }
          }
          return Arrays.stream(result)
                  .filter(Objects::nonNull)
                  .sorted()
                  .distinct()
                  .toArray(Integer[]::new);
      }
  
      private static long nthNonZeroMagicalNumber(final int N, final int smaller, final int larger) {
          final Integer[] stepsInCycle = steps(smaller, larger);
          final long lcm = stepsInCycle[stepsInCycle.length - 1];
          final int inOneCycle = stepsInCycle.length;
          final int fullCycleCount = N / inOneCycle;
          int count = fullCycleCount * inOneCycle;
          final long evaluated = fullCycleCount * lcm;
          if (count == N) {
              return evaluated;
          }
          final int remainder = N - count - 1;
          return stepsInCycle[remainder] + evaluated;
      }
  
      private static int greatestCommonDenominator(int a, int b) {
          while (b &gt; 0) {
              int temp = b;
              b = a % b;
              a = temp;
          }
          return a;
      }
  
      public static int lowestCommonMultiple(final int a, final int b) {
          return a * (b / greatestCommonDenominator(a, b));
      }
  
      public static int nthMagicalNumber(final int N, final int A, final int B) {
          if (N == 0) {
              return 0;
          } else if (A == B) {
              final long result = (long) A * (long) N;
              return modulate(result);
          } else if (N == 1) {
              return modulate(Math.min(A, B));
          }
          return modulate(nthNonZeroMagicalNumber(N, Math.min(A, B), Math.max(A, B)));
      }
  
      public static void main(String[] args) {
          int result = nthMagicalNumber(53776, 22434, 31343);
  
      }
  }
  </code></pre>
  
  <p>If someone can give me any advice I will really appreciate it. Thank you in advance!</p>