alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (lazy-override-run.scala)

This example Scala source code file (lazy-override-run.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

a, a, app, app, b, b, int, int, test

The Scala lazy-override-run.scala source code

class A {
  lazy val x: Int = { print("/*A.x*/"); 2 }
  lazy val y: Int = { print("/*A.y*/"); 2 }
  lazy val z: Int = { print("/*A.z*/"); 2 }
}

class B extends A {
  override lazy val x: Int = { print("/*B.x*/"); 3 }
  override lazy val y: Int = { print("/*B.y*/"); 3 }
  override lazy val z: Int = { print("/*B.z/"); 3 }
}




object Test extends App {
 val a = new A
 print("a.x=")
 println(a.x)

 val b = new B
 print("b.x=")
 println(b.x) 
 print("b.z=")
 println(b.z) 
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala lazy-override-run.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.