package
com.jn.scala.oop
/**
* @author jiangning
*/
class
Outer(
val
name
:
String
){
outer
=>
class
Inner(
val
name
:
String
){
def
foo
(
b
: Inner)=
println
(
"Outer:"
+
outer
.
name
+
" Inner : "
+
b
.
name
)
}
}
object
OOPInScala
{
def
main
(
args
: Array[
String
]){
val
outer1
=
new
Outer(
"Spark"
)
val
outer2
=
new
Outer(
"Hadoop"
)
// 内部类纯属于外部类的实例本身,对内部类进行创建。
val
inner1
=
new
outer1
.Inner(
"Scala"
)
val
inner2
=
new
outer2
.Inner(
"Java"
)
inner1
.
foo
(
inner1
)
// inner1. foo(inner2)//这样是不可以的
inner2
.
foo
(
inner2
)
}
}