package com.example.demo; //這是一個簡單的面向對象的例子,抽象具體事物變成模型 public class Person { //對象定義:對現實中具體事物(萬事萬物)的抽象 //對人進行抽象,應該有的屬性,嘴,腳 //嘴有吃這個功能,腳有走這個功能 //屬性:嘴 private String mouth; private String foot; //他們的方法 //嘴的吃 public void eat(){ System.out.println("mouth can eat"); } //腳的走 public void run(){ System.out.println("foot can run"); } public Person(){ } public static void main(String[] args) { //創建對象 Person person = new Person(); //調用人這個對象所擁有的功能 person.eat(); person.run(); } }