title: Array Index Out of Bound Exception - Scala
body: <p>I want to print a two dimensional matrix in Scala and I keep getting Array Index Out of Bound Exception.
  I have used breakable code and still I am encountering the issue.</p>
  
  <pre><code>package com.edureka.scala
  import scala.util.control.Breaks._
  
  class Pascal 
  {
    val r,c=0
    val matrix=Array.ofDim[Int](r,c) //declare a two-dimensional array
      def fun
        {
         breakable
           {
             for(r &lt;- 0 until 4 ;c &lt;- 0 until 4)
              {
                 println(matrix(r)(c)=r+c)
                 if(r&gt;3)break
              }
            }
        }
  }
  
  object pas1 extends App
  {
  
    val pasobj=new Pascal()
    pasobj.fun
  
  } 
  </code></pre>