Commit 21492cf3 authored by Thomas Dupriez's avatar Thomas Dupriez

ScalaJava interoperation example moved away from the graphics package, to a dedicated package

parent e22b9a02
......@@ -12,4 +12,4 @@ TO USE LIBRARIES:
SCALA/JAVA INTEROPERABILITY:
- An interesting document on the subject: http://www.codecommit.com/blog/java/interop-between-java-and-scala
- An example can be found in the Graphics code (which shows how the code from both the java and scala folder from the graphics group can cooperate). Just run the project using the GraphicsMain Class
- An example can be found in the scalaJava_interopExample code (which shows how the code from both the java and scala folder from the scalaJava_interopExample package can cooperate). Just run the project using the ScalaMain_InteropExample Class
package graphics;
public class Graphics {
public Graphics(){
}
}
\ No newline at end of file
package graphics;
public class JavaGraphics {
public String whatToSay = "Hi, I'm an object of the JavaGraphics class, from src/main/java/graphics/JavaGraphics.java";
public void sayHi (){
System.out.println(whatToSay);
}
}
package scalaJava_interopExample;
public class JavaClass_InteropExample{
public String whatToSay = "Hi, I'm an object of the JavaClass_InteropExample class, from /java/scalaJava_interopExample/JavaClass_InteropExample.java";
public void sayHi (){
System.out.println(whatToSay);
}
}
......@@ -2,10 +2,6 @@ package graphics
object GraphicsMain {
def main(args: Array[String]): Unit = {
println("Hi, I'm the object GraphicsMain, from /scala/graphics/Graphics.scala")
val jG = new JavaGraphics
jG.sayHi()
val sG = new ScalaGraphics
sG.sayHi()
println("Hi, I'm the object GraphicsMain, from /scala/graphics/GraphicsMain.scala")
}
}
\ No newline at end of file
// package graphics;
// public class GraphicsTestClass {
// // public static void main (String[] args){
// // System.out.println("Hello World");
// // }
// public void sayHi (){
// System.out.println("Hello, this is Graphics, from Graphics.java");
// }
// }
\ No newline at end of file
package graphics
class ScalaGraphics extends JavaGraphics{
whatToSay = "Hi, I'm an object of the ScalaGraphics class, which extends the JavaGraphics class. I'm from src/main/scala/graphics/Graphics.scala"
}
\ No newline at end of file
package scalaJava_interopExample
class ScalaClass_InteropExample extends JavaClass_InteropExample{
whatToSay = "Hi, I'm an object of the ScalaClass_InteropExample class, which extends the JavaClass_InteropExample class. I'm from /scala/scalaJava_interopExample/ScalaClass_InteropExample.scala"
}
\ No newline at end of file
package scalaJava_interopExample
object ScalaMain_InteropExample {
def main(args: Array[String]): Unit = {
println()
println("Hi, I'm the object ScalaMain_InteropExample, from /scala/scalaJava_interopExample/ScalaMain_InteropExample.scala")
val jC = new JavaClass_InteropExample
println()
jC.sayHi()
val sC = new ScalaClass_InteropExample
println()
sC.sayHi()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment