title: How to add a number on List in Scala(Beginner)
body: <p>I am just started learning Scala. I want to add numbers through loop and want to find out the minimum number. So, I did this</p>
  
  <pre><code>for(j&lt;-0 until numberOfQuery){
        val z = readLine.split(" ");
        var from = Integer.parseInt(z(0));
        var to = Integer.parseInt(z(1));
        var i=from;
        var getNumber = List[Int](to+1);
        var counter = 0;
        for(i &lt;-from until to+1){
            getNumber.apply(storeElemets(i));
            System.out.println(storeElemets(i));
        }
        System.out.println(getNumber.min);
      }
  </code></pre>
  
  <p>for input <code>10 20 30 40 11 22 33 44 15 5</code> and <code>0 5</code> the minimum number will be <code>10</code>. But, it returning <code>java.lang.IndexOutOfBoundsException</code>. So,</p>
  
  <p>1) What is the correct way to declare a <code>List</code> in Scala?
  2) What is my mistake ? What is the right way to add numbers.</p>