Use Java to start the object-oriented programming

zhaozj2021-02-12  204

Use Java to start the object-oriented programming

Do you are moving from traditional pro processs to target object-oriented development models? Or do you want to enter the expanded Java world? You don't feel lonely. Thousands of developers and you are in the same situation In this series of articles, we will use the Java language to lead you a step-oriented development process. Below is the first article of our series:

What does a language are object-oriented? If a programming language is a true object-oriented language, it must support the following features: Package - Hide Detail Polymorphism - Send the same message to different Objects and enable individual objects to respond to messages in a predetermined manner - expand the existing class to generate a state-of-the-art inheritance of the status and behavior of the original class. Dynamic binding - do not have to know the object when programming The specific type can send the ability to send messages to how Java supports these features and how it provides additional features to make the transformation process from procedural program to object-oriented development is relatively easy. Java Object-Oriented Features Java is an object-oriented (OOP) programming language published by Sun Microstems in the mid-1990s. You can download the latest Java development kit (JDK) from Sun's website. Java is an explanation Sexual language, which means that its source program is first compiled into the form of an intermediate code, and then the explanation of the virtual machine before running, it is a completely-directed object-oriented programming language. Java proofer hide a lot Traditional object-oriented programming languages ​​- computes C and Object Pascal - the complexity and confusing place. For example, there is no pointer in Java, Java will automatically clear the reference type for programmers, and all variables will It is automatically initialized into an appropriate default value. In addition to the original data type, all things in Java are objects. When necessary, it can also provide package mechanisms for the original data type. Object introduction object is the real life Software programming entities, such as bank accounts, computer users, buttons, windows, etc., windows, and more. Objects are defined by their status and behavior. For example, a bank account has a state, such as current revenue Status, owners of the account, the allowable minimum transaction amount, etc., and its behavior includes extraction, deposit, balance balance. The status of an object is defined by the variable that only objects you know. Java Variables are called data domains or members variables. Data domains are privately private unless explicitly use keywords to define their scope, allowing them to be visible to other classes. We will discuss the problem of variable scope. One object is defined by the operation above. In Java, these operations are called methods. Methods can change the status of an object, create new objects, implement practical functions. Class classes are an entity, it defines A object's operation mode and the data contained in the object when the object is created or instantiated. The role of the class is like a template, one or more objects can be created in accordance with it. Below is the object-oriented concept of object-oriented in the object Application Example: Public class helloworld {private string hellomsg = "Hello World!"; Public static void main (String [] args) {helloworld hw = new helloworld ();} public helloworld () {// Show our "Hello World" Message system.out.println (Hellomsg);

转载请注明原文地址:https://www.9cbs.com/read-6642.html

New Post(0)