title: How to make user input in java be of the type double?
body: <p>This line:</p>
  
  <pre><code>arr[i] = sc.nextDouble();
  </code></pre>
  
  <p>from this code:</p>
  
  <pre><code>public class z01 { 
    public static void main(String[] args) { 
      @SuppressWarnings("resource") 
      Scanner sc = new Scanner(System.in); 
      System.out.println("Enter array size: "); 
      int n = sc.nextInt(); 
      double[] arr = new double[n]; 
      double min = 0; 
      for(double i = 0; i &lt;n; i++){ 
        System.out.println("Enter element " + (i + 1)); 
        arr[i] = sc.nextDouble(); 
        if(i%3 == 0 &amp;&amp; i &lt;= min){ 
          min = i; 
        } 
      } 
      if(min != 0){ 
        System.out.println("The smallest number divisible by 3 is" + min); 
      } else { 
        System.out.println("No number is divisible by 3"); 
      } 
    } 
  }
  </code></pre>
  
  <p>Gives this warning:</p>
  
  <pre><code>Type mismatch: cannot convert from double to int 
  </code></pre>
  
  <p>How do I make user input in java be of the type double?</p>