본문 바로가기

Writing a class: fields, constructor, methods

English

Make your own type

  • So far you used classes like String and Math that Java gave you.
  • Now you will write your own class. A class is a plan for an object.
  • An object holds data (its own values) and methods (things it can do).

class Dog with fields name and age and a bark() method; new Dog("Rex", 3) and new Dog("Bella", 5) make two objects

교재 자료

로그인 또는 계정 만들기

IGCSE, A-Level & AP