--Java establish the foundation of my Java system (2) related to grammar

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/moye666/article/details/90812274

Java Basics (2)

Foreword

  Supposed to talk about what java runtime environment configured, but the online tutorials to build the operating environment is too much, I say it again here little significance. I'll talk about why Java runtime environment need to build it.
  First of all, known as cross-platform Java language, once written, can run on multiple platforms, it is because Java is in fact not run directly by the operating system, but run by the Java virtual machine. Popular to say that you just have to learn Java language and virtual machine to help you to translate your Java command to a different operating system on the line. Configuring the Java environment, in fact, it is to configure your virtual machine to install a translator.

Object-oriented Java

   As an object-oriented language Java, the slogan Everything object. When Java beginner always be fooled by the different interpretations of different people. Programmers mouth too much jargon, and they always think you also understand slang.
  We usually I understand object-oriented programming is that you or the person you want to operate affairs, the most representative attributes pulled out, and then operate.
For example: We want to be a student of class performance statistics.
First, we abstract a student out.
Students most representative attribute name, school, test scores, then we can put this several attributes as a class ;
written in Java code, then, is

public class Student{
    private int id;
    private String name;
    private String score;
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public int getScore() {
    return score;
}
public void setScore(int score) {
    this.score = score;
}
}

  A simple class that came out, this is a small unit of Java code. In general, we like to use this directly correspond to the database field, called entity classes. Under normal circumstances, our Java CRUD, is the class of these entities operate.
  Action class, we need these classes will be instantiated , it is an example of what? We copied about this class and the class of each property to fill the appropriate default, the class is instantiated out. Jargon is called a new subject; is instantiated class is called an object ; official following process:
Statement: declaring an object, including object name and object type.
Examples: Use the new keyword to create an object.
Initialization: Use to create a new object, it will call the constructor to initialize the object.

Student stu=new Student();

Class to change an object, that is, by one student became a student number is 1, the name is Joe Smith, the students took the test 59 minutes.

Guess you like

Origin blog.csdn.net/moye666/article/details/90812274