Packages

Other topics

Package structure

package com {
    package utility {
        package serialization {
            class Serializer
            ...        
        }     
    }
}

Packages and files

The package clause is not directly binded with the file where it is found. It is possible to find common elements of the package clause in diferent files. For example, the package clauses bellow can be found in the file math1.scala and in the file math2.scala.

File math1.scala

package org {
    package math {
        package statistics {
            class Interval
        }    
    }
}

File math2.scala

package org {
    package math{
        package probability {
            class Density
        }
    }
}

File study.scala

import org.math.probability.Density
import org.math.statistics.Interval

object Study {

    def main(args: Array[String]): Unit = {
        var a = new Interval()
        var b = new Density()
    }
}

Package naming convension

Scala packages should follow the Java package naming conventions.
Package names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example,

io.super.math 

Contributors

Topic Id: 8231

Example Ids: 26447,26536,28244

This site is not affiliated with any of the contributors.