Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Thinking in Java study notes - everything is an object     - Openfire Hazelcast cluster Detailed (Server)

- Top command: the Task Manager under linux (Linux)

- Share Practical Tutorial GitHub (Linux)

- The Hill sorting algorithm (Programming)

- On the design of Oracle database backup (Database)

- Install Firefox 28 on Ubuntu, Linux Mint (Linux)

- How to install Unbound and DNSCrypt in Archlinux (Server)

- GAMIT learning materials finishing (Linux)

- Linux server security - the web server configuration (Linux)

- Linux Powerful IDE - Geany configuration instructions (Linux)

- 64 Ubuntu 15.04 Linux kernel upgrade to Linux 4.1.0 (Linux)

- Oracle Sql Loader tool has shown signs (Database)

- RMAN backup file is much larger than the size of the database Cause Analysis (Database)

- Oracle 11g principle study Dataguard (Database)

- Ubuntu 14.04 compile and install Apache (Server)

- To install Xen in Ubuntu 12.04 (Linux)

- Udev: Device Manager for Linux Fundamentals (Linux)

- Java semaphores (Programming)

- Linux open handle limit adjustment (Linux)

- How a lot of blocking malicious IP address in Linux (Linux)

 
         
  Thinking in Java study notes - everything is an object
     
  Add Date : 2018-11-21      
         
         
         
  Foreword

Java is based on C ++, but Java is a more pure object-oriented programming language.

C ++ and Java are mixed / hybrid language. Heterozygous language allows multiple programming styles.

Manipulate objects with references

Each programming language has its own way to manipulate the memory element.

Direct manipulation element
Based on indirect representation in some special syntax (C and C ++ pointers)
With reference to manipulate objects (Java)
In Java, everything is treated as objects. Manipulation identifier is actually a reference to an object.

Analogy for the remote control (reference) to manipulate the television (the object)
So long as the remote control, you can stay connected to the TV
Change channels or decrease the volume, the actual manipulation of the remote control (reference), and then by the remote controller to regulate the television (the object)
Walk around the room, as long as the portable remote control (reference) instead of television (the object) TV will be able to Regulation
Even without the TV, remote control can also exist independently
        // Create an object reference instead of just
        String s1;
        // Create a reference while it initializes
        // Java language features: strings can be initialized with quoted text
        String s2 = "abcd";
        // More generic initialization method
        // Create a reference, and with a new object is associated
        String s3 = new String ( "abcd");
All objects must be created by us

Where to store

The program runs, placing arrangement, the memory assignment of all we have to understand.
There are five different places to store data:
1. Register
2. Stack
3. Heap
4. Constant storage
5. Non-RAM storage

Register: Located in a very limited number of registers, is the fastest memory, the register will be allocated according to demand, can not directly control, can not register any signs of the presence felt in the program

Stack: in the general RAM (random access memory) can be obtained by the stack pointer from the processor where direct support, the stack pointer is moved downward, the allocation of new memory, move up, then release that memory (this is a fast and effective storage allocation method, second only to register) to create a program, Java stored within the system must know the exact stack all the life cycle, in order to move up and down the stack pointer. ---> Limits the flexibility of the program, so some Java data (such as object references) stored in the stack, but Java objects are not stored in the stack

Heaps: common pool of memory (RAM area is located). Used to store all java objects. The compiler does not need to know that the data stored on the heap survive long (flexibility, but a longer time allocation and cleanup).

Constant storage: Store in the program code internally.

Non-RAM memory: data survived completely outside the program, without any control of the program, the program is not running may also be present. Such as stream objects, persistent object.

Exception: Basic type

a new object is stored in the heap, and therefore an object created with the new - particularly small and simple variables are often not very effective.
For these types, Java do not take to create a new variable, but not automatically create a variable reference (directly stored value and stored in the stack).

Java language for each share of the basic types of storage space is fixed, unlike other language changes randomly hardware architecture varies. (More portable)

     / **
         * Create a basic type is not a reference, but an automatic variable, direct store values, and stored in the stack.
         * Basic type has a corresponding wrapper class can create a heap of non-essential object that represents the basic types correspond.
         * /
        //basic type
        int i = 5;
        //type of packaging
        Integer integer = new Integer (i);
        // Java SE5 automatic packaging
        Integer integer1 = 4;
        // Reverse conversion
        int i1 = integer1;
     
         
         
         
  More:      
 
- Linux Network Programming - raw socket can do (Programming)
- Log device files under Linux - logger (Linux)
- Linux, grep, sed usage (Linux)
- Deploy Mono 4 and Jexus 5.6 on CentOS7 (Server)
- PL / SQL in forall simple test (Database)
- About AWR More Description (Database)
- Java Builder mode (Programming)
- ActionContext and ServletActionContext Summary (Programming)
- Ubuntu 14.04 LTS next upgrade gcc to gcc-4.9, gcc-5 version (Linux)
- 14 useful example Linux Sort command (Linux)
- MySQL 5.7.10 source code for the latest version of the installation process in detail (Database)
- Source compiler install Nginx (Server)
- The best tools and techniques to find data on a Unix system (Linux)
- UNIX how to restrict users by IP Telnet (Linux)
- Common data structures and functions of Linux process scheduling (Programming)
- Linux in order to make NMAP hide and seek with the firewall (Linux)
- Java concurrent programming using the synchronized keyword ReentrantLock alternative primitive (Programming)
- Ubuntu Gitolite management Git Server code base permissions (Server)
- How to Install terminator 0.98 on Ubuntu and Linux Mint (Linux)
- Lenovo E431 notebook CentOS system is installed wireless network card driver (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.