Understanding java-1.1 Programming Language Abstraction process and Java's basic features from the beginning

Source: Internet
Author: User
Tags unique id

In this chapter, we will briefly talk about the process of object abstraction.

1. All languages provide an abstraction mechanism.

For example: A=1 (The following are examples, the contents mentioned in it may be wrong, because the author did not learn the machine code and assembly)

In machine code: 1000100111011000

In the assembly: MOV a,1

In the C language: a=1

In Java:

Class Test () {   a=1;}

It can be found from the different representations above that the language is constantly abstracted, from the very beginning of 0 and 1, to the creation of an object in Java and then to the object, which is a continuous process of drawing.

At the same time, the programming language tries to relate the problem space (the actual business) with the solution space (computer) performance.

Explain:

1. In the age of machine code, the actual business with the computer direct connection is very difficult, we can see a=1 so simple operation, is a large segment of 0 and 1, who remember, of course, remember that live is the strongman.

2. In the age of compilation, the programming language progressed, making the first abstraction, abstracting 0 and 1 into certain sentences, and using simple sentences to describe the a=1, but because of the limited abstraction, the complexity of programming is still relatively high.

3. In the C language era, it can be said that the abstraction has made a leap, C language basically can deal with daily problems, and performance is very excellent

4. In the Java era, OOP has been proposed, which makes the description of the actual business and the computer solution more consistent.

Summarize:

4 times of change, performance is getting lower, but more and more readable, today, unless it is a high-concurrency Internet enterprises, generally speaking, performance is not the biggest problem, bottlenecks appear on top of people, so now readability is more important.


Basic features of 2.java

1) All things are objects.

An object is a peculiar variable that can store data or perform operations, and we can compose programs by abstracting the components of the problem.

For example, a dog with the name "Jack" would bark.

Class Dog () {  private String name;  Private String ID;    public void bark () {  }}
We build the dog's object, and then this dog has a property "name", and it will be called, so there's a way to "bark"

In the object dog, you can either store the name of the dog or perform the method of barking.


2) programs are collections of objects that tell each other what they need to do by sending information (plainly, the method that invokes the object).

Package Com.ray.ch01;public class Test {public static void main (string[] args) {Dog dog = new Dog ();d og.setname ("Jack");d O G.bark ();}} Class Dog {private String name;public void bark () {System.out.println (name + "is Barking");} Public String GetName () {return name;} public void SetName (String name) {this.name = name;}}

In the program above, Dog.bark () is the Bark method that invokes the dog object.


3) Each object has a store that consists of other objects.

Package Com.ray.ch01;import Java.util.arraylist;public class Groupofdogs {private arraylist<cat> catList; private void Initcatlist () {for (int i = 0; i < 5; i++) {Cat cat = new Cat () Cat.setname ("Rose" + i); Catlist.add (Cat);} }public static void Main (string[] args) {new Groupofdogs (). Initcatlist ();}} Class Cat {private String name;public void bark () {System.out.println (name + "is Barking");} Public String GetName () {return name;} public void SetName (String name) {this.name = name;}}

As you can see from the code above, especially the private arraylist<cat> catlist, this store is done by other objects.


4) Each object has a type

Package Com.ray.ch01;public class Bird {public static void main (string[] args) {Bird Bird = new Bird ();}}

The above code, bird, is an object whose type is bird, while bird this object, which is also an instance of the bird type.


5) A particular type of object can receive the same message.

Package Com.ray.ch01;public class Bird {private void Say () {}public static void main (string[] args) {Bird bird1 = new Bird (); Bird1.say (); Bird bird2 = new Bird (); Bird2.say ();}}


The above code builds two different objects bird1 and Bird2, they are the same type bird, so they can receive the same information, that is, say and bird1 can be called when I need to invoke the Bird2 method inside the bird type.


Finally, the object is a separate storage, method, identity, inside the JVM, each object is independent and has a unique ID.


This chapter briefly introduces the process of programming language abstraction and introduces the five basic features of Java.


This chapter is here. Thank you.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Understanding java-1.1 Programming Language Abstraction process and Java's basic features from the beginning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.