Is it possible to import custom java classes into Scala? -


What I'm still trying to learn is Scala, I saw that this is very much with Scala Java Friendly. "You can call methods of other methods in some other way." But I am being imported into a custom Java class scala and could not find a suitable example for using it. So what is it possible to wonder? Can you advise this newbie?

I am using Notepad, and not an editor (running on many issues in using Eclipse).

I have an employee class in Java:

  package emp; Class employees {string name; }  

And it is trying to import into my Scala class

  Import Emp._ Object Emp Employees Enhances {..... ..}  

But it just does not compile. It is a wonder that something is missing in concept or syntax; help please.

Yes, this is possible. Your employee category, however, is not public add a public modifier, and it should work.

You should also check that your classpath is correct. The best way to make sure that everything is okay is to use the build tool like SBT if you use SBT and its traditional directory layout (scala source in src / main / scala Adhere to java sources in src / main / java ), then scala classes will be able to see their Java counterparts more easily.

However, according to the small source code you have presented, you can also fight a name. You have a package named emp and emp ; Package and Classes / Objects share name space in Scala and Java, so you can not make a package and completely unrelated objects with the same name at the same time. I recommend changing the name of the package in some more phrases.

View summary file names are entangled because the song does not allow slash in file names (so I changed them with a dash), but you get the main idea, I believe.


Comments