"Java" Java basics

Source: Internet
Author: User

1. The difference between int and integer

int is the basic data type, and integer is a reference data type.

e.g:

int num = 100; Not an Object

Integer i = 100; is an object

Num. Properties and methods are not out of order

I. Point-out properties and methods

Integer is the boxed class of the integer type, which can be boxed and unboxing

i = num; Automatic Boxing

num = i; Automatic unpacking

Boxing--"Converting a value type to a reference type

Unpacking-"Converting a reference type to a value type"

-Integer is an int type encapsulation class, int is not an object       base type ->integer is an object   reference type

2, = = and equals () the difference?

for = =, if both sides are numeric values, indicate whether the values are equal, if the two days are reference types, the objects are the same. ->equals () to determine whether the contents of the two objects are the same.

 String s1 = "Hello" ; string s2  = new  String ("Hello"  = new  String ("Hello"  = = s2); //  SYSTEM.OUT.PRINTLN (s2 = = s3); //  system.out.println (s1.equals (S2));  //  System.out.println (S2.equals (S3)); //  
string S1 = "Hello"= "Hello"new String ("Hello"//  true//  false//  true//   True

"Java" Java basics

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.