1, what is a class?
A: The class is an objective, abstract, conceptual thing.
2, what is an object?
A: The object is concrete, practical, representing a thing. For example: A car is a class, a car, a bicycle is his object.
About classes and objects: A class is a template for an object that is an individual of the class.
How do I define a class in 3,java?
Class name defines human in Java syntax: public class person{}
4, how is the object defined?
1, Object declaration: Class name Object name; 2, object creation Object name = new class name (); new function: allocates memory space.
Can also be written as: Class Name Object name = new class name ();
5, Example: Create an air conditioner and call the refrigeration.
Design an air-conditioning package Practice;public class Kongtiao { ///Air Conditioning 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 = "air conditioning"; Kt.pishu = "2 Horses"; Kt.tempeture =; Kt.pinpai = "Gree"; /** Kt.cool (); System.out.println ("The temperature of the air conditioning is" +kt.tempeture); * /Kt.hot (); System.out.println ("The temperature of the air conditioner is" +kt.tempeture);} }
2015-3-29 Java class, object definition and usage