Old saying: everything is object, everythingobject
Preface: Everything is object, OK. I finally got a very foreign name. I instantly felt that I was an object Writer, and what I was doing was writing: "Writer. writing (CSDN )".
Reference operation object
Actually, I don't want to discuss this topic. I am really allergic to "reference" and "object". I may have understood it one second ago, And I will be confused one second later, I am a little awake now.
String s;System.out.println(s);
Do you think the above Code can be executed?
Of course, the answer is no!
If you use IDE, you will be reminded that s is not initialized. For example, there are seven gourd dolls (doll 1, 2 2, 3 3, 4 4, 5 5, 6 6, and 7, I knocked it out one by one). If at this time, Grandpa huluwa shouted "Baby, come back for dinner", maybe seven huluwa couldn't respond, but I don't know which baby Grandpa called, in this case, the baby in the grandfather's mouth is a reference and has not yet formed an object.
If grandpa calls "1, move bricks and Grandpa sit down" (), or calls" 2, pour saliva to grandpa" (is water ), in this way, the children can understand Grandpa's meaning.
String s1 = "w1"; String s2 = "w2"; System. out. println (s1 + "move bricks for ye," + s2 + "Pour saliva for ye ");
Speaking of this, do you understand the reference operation object? I seem dizzy again.
Basic Type
For the basic types of Java, I think you must know the following.
| Basic Type |
Package Type |
| Boolean |
Boolean |
| Char |
Character |
| Byte |
Byte |
| Short |
Short |
| Int |
Integer |
| Long |
Long |
| Float |
Float |
| Double |
Double |
| Void |
Void |
Here, I just want to explain why there is a basic type?
Next I will first cut the newspaper:
Register> stack> heap> constant storage> non-RAM Storage
What do you mean? That is, the Register is the fastest storage area in the computer, followed by the stack, and so on.
What does this have to do with the basic type?
When Java uses new, it stores the object in the heap, while the basic type is a very simple object. If it is also in the heap, it will affect the performance, in view of this, the basic type is put into the stack, which is more efficient.
Of course, when you see this, you may think of Java programming ideas. I didn't want to explain it, but I couldn't help it. I was afraid of being said as a porter. OK. I think of the syntax of Nongfu Spring: "We do not produce water. We are just the porters of nature ".
Garbage Collection
Originally, I wanted to put two dynamic graphs. As a result, CSDN told me that the file size exceeds 2 MB, so I can only paste the website, but there are a lot of advertisements in it. Please be patient.
It is said that the garbage collection between C ++ and Java is a comparison between Image Code farmers.
I don't know what to say.
Static keywords
Cut the newspaper first.
A static field has only one bucket for each class, and a non-static field has a bucket for each object.
Class T1 {static String s = "";}
Is there a problem with this code?
Yes. At least the IDE will prompt you that s should be declared as the final type. What does this mean? You can go back to the newspaper clipping and take a look.
In this article, let's talk about this. I think it's time to end. The points of attention I want to talk about are over. What should I refer to below? I want to do something, right!
Can you answer the following questions?
class T1 { int i; char c; String s; }public class Test { public static void main(String[] args) { T1 t1 = new T1(); System.out.println(t1.i); System.out.println(t1.c); System.out.println(t1.s); }}
Please answer.
2. What do you think is the answer?
class T1 { String s; static void callMe(T1... t) { t[0] = t[1]; t[1].s = "new s"; }}public class Test { public static void main(String[] args) { T1 t1 = new T1(); T1 t2 = new T1(); t2.s = t1.s = "s"; T1.callMe(t1, t2); System.out.println(t1 + " " + t2); }}
The printed result is:
1. t1 t2;
2. new s;
3. t1 t1;
4. The above answers are all incorrect.
Copyright Disclaimer: All blogs on this site are original articles of qing_gee. If you need to reference and repost, you only need to specify the source and original link.