class Test 1 class int age attribute double
Sign up to view full document!
SIGN UP
class Test 1{ class int age; attribute double salary; void method 1(){ //วธการ ทำงาน ตวแปร local method } public static void main(String[] args) { t 1 คอ ตวแปร Object Test 1 t 1=new Test 1(); System. out. println(“age is ”+t 1. age); เรยกใช ตวแปร attribute t 1. salary=50; System. out. println(“ salary is ”+t 1. salary); ผาน t 1. method 1(); เรยกใช method ผาน t 1 } }
class Test 1{ class static int age; static double salary; attribute static void method 1(){ //วธการ ทำงาน ตวแปร local method } public static void main(String[] args) { เมอสรางตวแปร และ System. out. println(“age is ”+age); method เปน static สามารถเรยกใชตวแปร salary=50; และ method นนๆ System. out. println(“ salary is ”+salary); ไดเลย method 1(); } }
- Slides: 23