Java Translation Object Oriented Concept Object Class Name
Java Translation
Object Oriented Concept
คำสงสราง Object จากคลาส Class. Name class. Variable = new Class. Name(); Class cat. Game{ String flurcolor; void maew(){ System. out. println(“maew”); } } Cat. Game srisawat = new Cat. Game();
Class Dog // Class Declaration class Dog { // Instance Variables String breed; String size; int age; String color; } // method 1 public String get. Info() { return ("Breed is: "+breed+" Size is: "+size+" Age is: "+age+" color is: "+color); }
Dog. App public class Dog. App{ public static void main(String[] args) { Dog maltese = new Dog(); maltese. breed="Maltese"; maltese. size="Small"; maltese. age=2; maltese. color="white"; System. out. println(maltese. get. Info()); } }
Lab 2 - Print address of dog object System. out. println(mastiff); System. out. println(chow); System. out. println(maltese);
Object ทเกดใน mastiff chow maltese memory
lab 3 • Linklab 3 –Box
. 9เพมคำสงตอทายคลาส ดงน Example 2 class Example 2 { public static void main(String args[]) { System. out. println("Hello …"); } } 10. Run clean build 11. ไปท tab file folder dist 12. ม class file ทเกดขนชออะไรบาง
- Slides: 31