当前位置:网站首页>Scala sample class
Scala sample class
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
// Sample class
// Scala in , The sample class is a special class , It is generally used to save data ( Be similar to Java Bean), In concurrent programming and Spark、Flink It is often used in these frameworks
// Format
// case class Sample class name ([var/val] Member variable name 1: type 1, Member variables 2: type 2, Member variable name 3: type 3){}
//
// If you don't write , The default modifier of the variable is val, namely val Omission
// If you want to implement a member variable, the value can be modified , You need to add it manually var To modify variables
object Sample class {
case class Person(name: String = " Zhang San ", var age: Int = 10) {
}
def main(args: Array[String]): Unit = {
val p = Person()
println(s" Before the change :name = ${p.name}, age = ${p.age}")
// p.name="" // Report errors , The default modifier without is val, Do not modify the
p.age = 18
println(s" After modification :name = ${p.name}, age = ${p.age}")
}
}
边栏推荐
- Text editor of QT project practice ---------- episode 8
- Add information on the left and add parts on the right of the status bar
- Paint rounded rectangle
- 2022熔化焊接与热切割复训题库模拟考试平台操作
- Kubernetes 架构核心组件工作原理解析
- Thermodynamic diagram display correlation matrix
- 2021-11-07
- QT (36) -rapidjson parsing nested JSON
- 移动安全工具-jarsigner
- ros(25):rqt_image_view报错Unable to load plugin for transport ‘compressed‘, error string
猜你喜欢

In the process of enterprise development, I found that a colleague used the select * from where condition for update

Apk decompiled method (not confused)

Simulation questions and answers of the latest national fire facility operator (senior fire facility operator) in 2022

ServerSocket and socket connection

Virtual machine - network configuration

Using tcp/udp tools to debug the yeelight ribbon

Technologie des fenêtres coulissantes en octets dans la couche de transmission

Easy to wear - drop down radio

Rich text tables, lists, pictures

2022R1快开门式压力容器操作考题及答案
随机推荐
Introduction to smart contract security audit delegatecall (2)
ros(24):error: invalid initialization of reference of type ‘xx’ from expression of type ‘xx’
A website for programmers with a monthly salary of 30K
Examination questions and mock examination for safety management personnel of hazardous chemical business units in 2022
Text editor of QT project practice ---------- episode 11
In the process of enterprise development, I found that a colleague used the select * from where condition for update
最新QQ微信域名防红PHP程序源码+强制跳转打开
Applet opening traffic master
Garbage collection of C closure
Network request -volley
The acceleration of 100 km is only 5.92 seconds, and the willanda high-performance version leads with the strength of high-energy products
[microservices sentinel] sentinel quick start | building an image | starting the console
placeholder
2021-11-07
【微服务|Sentinel】Sentinel快速入门|构建镜像|启动控制台
Helm chart仓库操作
2022R1快开门式压力容器操作考题及答案
断言(assert)的用法
Mobile security tool jarsigner
QT electronic clock