Anonymous Inner Class in Scala PRO

Scala allows us to define anonymous inner classes. The syntax is very similar to the one we know in Java.

object Demo
{
  def main(args:Array[String]):Unit =
  {
    val ob = new MyStack[Int](0)
    {
      def data:Nothing = throw new Exception("empty stack");
    }
  }
}

abstract class MyStack[T](size:Int)
{
  def data:T;
}

The following video clip overviews this code sample.

Share:

banner for the css playlist in hebrew life michael courses for programmers

The First Steps in CSS

Learn CSS using our our videos (in Hebrew) on the CSS (he) playlist on youtube. Do it now. Do it for free.

Good Trainers Collaborate with Others

It is always essential to keep an open mind and learn from others. This applies to everyone, including teachers and especially software development trainers. Software

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences