How Scala code gets compiled into Java

For last few days i am learning Scala + play framework. Since i have been using Java for long time now, one that always helps is to convert Scala code into Java Code and see what is going on under the hood. I follow these steps
  1. First i create a new Scala File say Contact.scala which has one Scala class like this
    class Contact{
       var firstName =""
       private var lastName = ""
  2. Then go to the directory that has Contact.Scala and compile it using scalac Contact.scala, The scala compiler will create .class files for every class in that .sclaa file in appropriate package. In my case i have only one class in my Contact.scala so it creates Contact.class
  3. Next use javap Contact and and i can see following output being generated on the command line
    Compiled from "Person.scala"
    public class Contact extends java.lang.Object{
        private java.lang.String firstName;
        private java.lang.String lastName;
        public java.lang.String firstName();
        public void firstName_$eq(java.lang.String);
        private java.lang.String lastName();
        private void lastName_$eq(java.lang.String);
        public Contact();

1 comment:

Sonendra Choudhary said...

9643950605 Croma Campus is one of the best Angularjs Training in Noida with 100% situation ensures. Croma Campus has very much characterized course modules and instructional meetings for understudies and Weekend classes, evening clump classes with live venture by industry master In Noida.