title: toString function in Scala
body: <p>I'm new to Scala, I was reading about scala from the following source: <a href="http://docs.scala-lang.org/tutorials/tour/classes" rel="nofollow">http://docs.scala-lang.org/tutorials/tour/classes</a></p>
  
  <p>It had the following code:</p>
  
  <pre><code>class Point(var x: Int, var y: Int) {
    def move(dx: Int, dy: Int): Unit = {
      x = x + dx
      y = y + dy
    }
    override def toString: String =
      "(" + x + ", " + y + ")"
  }
  object Classes {
    def main(args: Array[String]) {
      val pt = new Point(1, 2)
      println(pt)
      pt.move(10, 10)
      println(pt)
    }
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>(1, 2)
  (11, 12)
  </code></pre>
  
  <p>I wanted to ask how did the <code>println(pt)</code> function printed the result <code>(1,2)</code>? Should we not call <code>pt.toString()</code> to print the result as shown? </p>