scala中math包_Scala中的软件包

scala中math包

Scala软件包 (Scala Packages)

In Scala, Packages are used to put classes, sub-packages, traits and other packages together. It is the namespace of code in files and directories in the Scala programming language. It is used to maintain code into folders isolating them from other members. Also, managing their access of members using access specifiers like public (when nothing is specified), package specific, protected, private.

在Scala中, 用于将类,子包,特征和其他包放在一起。 它是Scala编程语言中文件和目录中代码的名称空间。 它用于将代码维护在文件夹中,以使其与其他成员隔离。 另外,使用访问说明符(如public(未指定任何内容),特定于包,受保护的,私有的)来管理对成员的访问。

Declaring a Package in Scala

在Scala中声明一个包

The first statement of a Scala programming is package declaration in Scala.

Scala编程的第一条语句是Scala中的程序包声明。

Syntax:

句法:

    package package_name

You can also define packages in some different ways in Scala,

您还可以在Scala中以某些不同的方式定义包,

    package x.y.z 

    // or 

    package x
    package y
    package z

Scala中的软件包工作 (Working of packages in Scala)

Packages are files that are used to encapsulate data and storing data into files. Packages are similar to the directory structure. It will locate classes that are directories in easy-access locations.

包是用于封装数据并将数据存储到文件中的文件。 软件包类似于目录结构。 它将在易于访问的位置找到属于目录的类。

The naming convention is reverse order for packages i.e. com.includehelp.scala.

软件包的命名约定是相反的顺序,即com.includehelp.scala

Adding Members to a Package in Scala

在Scala中将成员添加到包中

In Scala, new members can be added to a package. Members like classes, subclasses, traits, objects, sub-packages. In Scala, you can add different files in the same package.

在Scala中,可以将新成员添加到包中。 成员喜欢类,子类,特征,对象,子包。 在Scala中,您可以在同一包中添加不同的文件。

Syntax:

句法:

    package bike
    class BMW {
        val GS 310r
    }

Example:

例:

// package bike has other classes like harley, etc. 
package bike
class BMW {
    val bike_name;
    def display_name(){}
}
object MyClass {
    def main(args: Array[String]) {
        val gs310r = new BMW();
    }
}

Using packages in Scala

在Scala中使用软件包

Packages are used to import members in Scala programming. The import keyword is used to add members in Scala.

包用于在Scala编程中导入成员。 import关键字用于在Scala中添加成员。

Example:

例:

// package bike has other classes like harley, etc. 
import bike
object MyClass {
    def main(args: Array[String]) {
        val gs310r = new BMW();
        val street750 = new harley(); 
    }
}

翻译自: https://www.includehelp.com/scala/packages.aspx

scala中math包

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值