Using #Scala for quickie Java hints

I’ve never had the time to invest in Scala but it has it’s uses for Java work.

For a quick and handy test of those we reminders you need once in a while use the Scala shell, it saves diving in to your IDE and coding up something quick.

So fire up your Scala shell and then start typing Java……

Jason-Bells-MacBook-Pro:bin Jason$ ./scala
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import java.util.Date;
import java.util.Date
scala> var date = new Date();
date: java.util.Date = Mon Sep 02 19:46:45 BST 2013

scala> var startdate = new Date(0L);
startdate: java.util.Date = Thu Jan 01 01:00:00 GMT 1970

scala> var uuid = java.util.UUID.randomUUID.toString();
uuid: java.lang.String = 7990eb01-3381-4f80-bd6c-f4b79dccb924

scala>

2 responses to “Using #Scala for quickie Java hints”

  1. If you have sbt installed, you can do this with third party libraries, as well (hopefully the formatting won’t butcher this paste):

    sbt ‘;set libraryDependencies += “net.debasishg” %% “redisclient” % “2.10”; set initialCommands := “import com.redis._”; console’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: