5. ตัวอย่างของตัวอย่างของ PrimitivePrimitive && ReferenceReference
TypeType
Primitive TypePrimitive Type
Primitive TypePrimitive Type CodeCode
int a = 5;int a = 5;
a = 5a = 5
int b = 10;int b = 10;
b = 10b = 10
a = b;a = b;
a = 10a = 10
MemoryMemory
ReferenceReference TypeType CodeCode
Circle a = new Circle(5);Circle a = new Circle(5);
ReferenceReference TypeType
MemoryMemory
a 5
Circle b = new Circle(20);Circle b = new Circle(20);
b
20
a = b;a = b;
6. Scope of variableScope of variable
Scope of variableScope of variable หรือขอบเขตของ ตัวแปรหรือขอบเขตของ ตัวแปร
ตัวแปรโดยส่วนมากแล้วจะมีขอบเขตเป็นตัวแปรโดยส่วนมากแล้วจะมีขอบเขตเป็น
Global variableGlobal variable และและ Local variableLocal variable
Global variableGlobal variable คือตัวแปรที่สามารถเข้าถึงได้คือตัวแปรที่สามารถเข้าถึงได้
จากทั้งจากทั้ง ClassClass
Local variableLocal variable คือตัวแปรที่เข้าถึงได้เฉพาะในคือตัวแปรที่เข้าถึงได้เฉพาะใน
MethodMethod
7. What is Global and Local variableWhat is Global and Local variable
listlist
namename
langslangs
myArraymyArray
21. UML Class Diagram ExampleUML Class Diagram Example
CarCar
-name:string-name:string
-price:int-price:int
-color:string-color:string
+Car(string:name,int:price,string:color)+Car(string:name,int:price,string:color)
++getName():stringgetName():string
+getPrice():int+getPrice():int
+getColor():string+getColor():string
/*
Class Name
State
Behavior
+ public
- private
*/