A little more java every day (4)

Source: Internet
Author: User

1. Static methods cannot be overloaded.
2. Final defines constants and cannot be overloaded or changed.
3. Transient defines non-serializable variables, which can only reside in the memory without the need for hard disk storage or network transmission.
4. Volatile indicates the variables that can be operated asynchronously. It is mostly used for multithreading.
5. Finalize sends a garbage collection request. The JVM implements garbage collection based on the situation. It is not recommended to display the call.
6. This indicates the current object, which is mainly used to differentiate variable calls and call Constructor (the first statement that can create another function, in other words

, Can only be called once); Super is for the parent class this.

 

Code:

Class testthis
{
Testthis ()
{
System. Out. println ("testthis ()");
// This ("Haha ");
// This ("Heihei ");
}
Testthis (string text)
{
This ();
System. Out. println ("textthis (string text)" + text );
}
Public void Prin ()
{
// This ();
// This ("Prin ");
System. Out. println ("Prin ()");
}
Public static void main (string [] ARGs)
{
Testthis testthisobj1 = new testthis ();
Testthis testthisobj2 = new testthis ("testthisobj2 ");
Testthisobj1.prin ();
Testthisobj1.finalize ();
Testthisobj1.finalize ("Hoho ");
Testthisobj1.finalize ();
Testthisobj1.finalize ("Hoho ");
Testthisobj1.prin ();
}
Protected void finalize ()
{
System. Out. println ("Haha ");
}
Protected void finalize (string Str)
{
System. Out. println ("string Str" + Str );
}
}

 

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.