Java
There are two features of Java.
The idea is to create one program as an "object". Because it is a way of thinking, many learners are troubled. Object-oriented has three characteristics.
・ Inheritance ·Encapsulation ・ Polymorphism
I will briefly describe the above three features. "Inheritance" is to inherit the characteristics and properties. "Encapsulation" is the protection of data and values. "Polymorphism" is a method that allows others to change little by little based on one framework.
In Java programs, there is a class file called ".class" that can be done through "compilation" work that checks the grammar etc. from the source file ".java". This class file can be run anywhere you have a Java VM (Java Virtual Machine). Why can it work anywhere with a Java VM? There are two reasons, the first is "JavaVM executes the class file". The second reason is that "Java VM absorbs the difference even if the OS is different".
A "variable" is like a box that holds data. There are three things I've learned with variables.
A static variable is a variable that can be shared by one ~~ method ~~ instance and another ~~ method ~~ instance. Suppose you have methods A and B. Suppose you have each shared static variable. If you change the value of one variable, the compilation will not work unless you change the value of the other variable.
Member variables are variables defined in a class. class A{ int b = 10; ・ ・ ・ } It's like the int type variable b above. Member variables can be used with any method defined in the class.
Local variables are variables defined within a method.
class A { int b = 10; // member variable public void methodc(){ int d = 20; // local variables } public void methode(){ int f = 30; // local variables System.out.println (f); // Displayed } }
The range of access differs depending on whether it can be output with member variables or local variables. Such a range is called a "scope".
Next time I will write "array" etc.
Recommended Posts