Person represents a human abstract concept in Java, implemented through a Java class that defines properties and methods. Usually contains attributes (name, age, gender, occupation) and methods (self-introduction, conversation, work).
What does person mean in Java?
In Java,person
is an abstract concept, usually used to represent a person with attributes and behaviors. It can be implemented through Java classes that define properties and methods related to people.
Attributes
person
class usually has the following attributes:
Methods
The person
class can also have the following methods:
person
introduce itself to its attributesperson
to talk to otherperson
Talkperson
perform tasks related to their careerAchieve
The following is a sample Java code that implements theperson
class:
public class Person { private String name; private int age; private String gender; private String occupation; public Person(String name, int age, String gender, String occupation) { this.name = name; this.age = age; this.gender = gender; this.occupation = occupation; } public void introduce() { System.out.println("My name is " + name + ", I am " + age + " years old, I am a " + gender + ", and I am a " + occupation + "."); } public void talk() { System.out.println("Hello, how are you?"); } public void work() { System.out.println("I am working on a project."); } }
Usage
person## can be created and used using the following code #Instance of class:
Person john = new Person("John Doe", 30, "male", "software engineer"); john.introduce(); john.talk(); john.work();
My name is John Doe, I am 30 years old, I am a male, and I am a software engineer. Hello, how are you? I am working on a project.
The above is the detailed content of What does person mean in java. For more information, please follow other related articles on the PHP Chinese website!