1, what is a class?
A: The class is an objective, abstract, conceptual thing.
2, what's the object?
A: The object is concrete, practical, and represents a thing. For example: A car is a class, a car, a bike is his object.
A description of classes and objects: A class is a template for an object and an object is an individual of a class.
How do you define a class in 3,java?
Class class name
defined in Java syntax Human: public
class person
{
}
4. How do I define an object?
1, Object declaration: Class name Object name;
2, object creation Object name = new class name (); new function: Allocate memory space.
It can also be written as follows: Class Name Object name = new class name ();
5, Example: Create an air conditioner and call refrigeration.
Design an air-conditioning
package practice;
public class Kongtiao {
//Air conditioner property
String name;
String Pinpai;
String Pishu;
int tempeture;
Define refrigeration behavior
void Cool ()
{
tempeture--;
}
Define heating behavior
void hot ()
{
tempeture+=7;
}
Main function public
static void Main (string[] args) {
Kongtiao kt = new Kongtiao ();
Kt.name = "Beautiful";
Kt.pishu = "2 Horses";
Kt.tempeture =;
Kt.pinpai = "Zhi Gao";
/**
Kt.cool ();
System.out.println ("The temperature of the air-conditioner is" +kt.tempeture);
* *
kt.hot ();
System.out.println ("The temperature of the air-conditioner is" +kt.tempeture);
}
The above analysis of Java programming class and object definition is small to share all the content of everyone, hope to give you a reference, but also hope that we support cloud habitat community.