Thinking in Java 16/3/6

Source: Internet
Author: User

object and base type :

string s = new String ("abc");

S is a reference, referencing an object with a value of ABC, which is stored in the heap

Basic type : As a special "basic type" in Java, (for efficient processing of data), that is, not to create a variable with new, but rather to create an "automatic" variable that is not a reference. This variable stores the value directly and places it on the stack.

features : The basic types in Java do not change as the hardware architecture changes, uniquely determining the size of the storage space, unlike the basic C + + data

Basic types and wrapper types

Boolean Boolean

Char Character

BYTE byte

Short Short

int Integer

Long Long

float float

Double Double

void void

you can use the wrapper type in the heap to correspond to the basic types that exist in the stack :

char c = ' x ';

Character ch = new Character (c); Character ch = new Character (' X ');

Charcter ch = ' x '; (Automatic conversion, ' X ' automatically converted to an object, then referenced by CH)

char c = ch; (Reverse conversion)

In summary: That is, C and ch " pricing "

Class: field + method

Fields :

the base type in the field is the normal basic type :

Object of base type in field : Default value Exists

Objects of the ordinary basic type definition : If no initialization is directly considered an error in Java, the compiler in C + + will only warn

Method :

method is called by an object and A.F () is understood to send a message to an object

stactic fields and methods : All objects of the same class share the same storage space, and can be called directly with the class name without invoking a specific object

Thinking in Java 16/3/6

Related Article

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.