Software Secret Weapons™

 
Scala to Java Cheat Sheet
by Pavel Simakov on 2008-03-21 01:32:40 under Lambda, view comments
Bookmark and Share
 

Scala is Java, but there are syntactic differences... Here is my quick Scala to Java cheat sheet to help me remember Scala and how it relates to Java. There are more cheat sheets in the Sundararajan's Weblog.

Java Scala
package com.oy.shared.scala; package com.oy.shared.scala
import java.io.*; import java.io._
public static class HelloObj { ... } object HelloObj { ... }
public class HelloObj { ... } class HelloObj { ... }
System.out.println("Foo!"); println("Foo!");
public class MyClass implements Filter { ... } class MyClass extends Object with Filter { ... }
public void destroy() { ... } def destroy() : Unit = { ... }
void scala.Unit
public void foo(){ ... } def foo() : Unit { ... }
  import Fruits.{Apple => McIntosh, Orange}
public void foo() throws RuntimeException {} @throws(classOf[RuntimeException])
def foo(){ ... }
java.lang.Object scala.AnyRef
   

No comments yet


Leave a comment


  Copyright © 2004-2012 by Pavel Simakov
any conclusions, recommendations, ideas, thoughts or the source code presented on this site are my own and do not reflect a official opinion of my current or past employers, partners or clients