Home > Java > Javagetting Started > What is a class in java

What is a class in java

(*-*)浩
Release: 2019-11-15 10:29:38
Original
9869 people have browsed it

java类就是具备某些共同特征的实体的集合,它是一种抽象的数据类型,它是对所具有相同特征实体的抽象。在面向对象的程序设计语言中,类是对一类“事物”的属性与行为的抽象。

What is a class in java

类:类是一个模板,它描述一类对象的行为和状态。

类的声明                  (推荐学习:java课程

class 类名{  
    类体的内容
}
Copy after login

class是关键字用原来定义类,类名必须是合法的java标识符

Java中的类

类可以看成是创建Java对象的模板。

通过下面一个简单的类来理解下Java中类的定义:

public class Dog{
  String breed;
  int age;
  String color;
  void barking(){
  }
 
  void hungry(){
  }
 
  void sleeping(){
  }
}
Copy after login

The above is the detailed content of What is a class in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template