Javase Tip 2

Source: Internet
Author: User

1. Windows
    • Close the form:
    • Method 1:set Defaultcloseoperation (Jframe.exit_on_close)
    • Method 2:
    • Add WindowListener (New Windowadapter () {
    • public void windowclosing (WindowEvent e) {
    • System.exit (0)
    • }
    • Run:
    • public static void execute (String cmd) {
    • Runtime r = Runtime.get runtime ();
    • R.exec (CMD)}

1.1 Differences in using collections
    • Linkedhashset Add Delete
    • HashSet find
    • TreeSet sort
2. Multithreading
    • Process: The program being executed
    • Threads: Execution Units

    • Synchronized (this) {
    • Locked content
    • }
    • Thread Sleep
    • try{
    • Thread.Sleep (1000);
    • }catch (Exception e) {
    • e.getmessage;//getting error messages
    • E.printstacktrace ();//Get stack error message
    • }
3. Arrays
    • Arrys.sort () sort
    • Arrys.tostring ()
    • Arrys.deeptostring (); multidimensional arrays
4. Garbage Object Recycling
    • System.GC ()//Mandatory garbage collection
    • Finalize () Method: Garbage Collection

5. Garbled conversion

    • byte[] data = username.getbytes ("iso-8859-1")
    • Username = new String (data, "Utf-8")
6. Object-oriented
  • inheritance keyword: extends
  • Calling the parent class
  • Construction Method : Super (); Must be the first sentence, not inherit
  • method : Super. Method
  • Override Overrides, Overrides
  • polymorphic
  • 1. The operation of an object is determined by the type of claim
  • 2. Specific implementation is determined by the object
  • Richter Replacement : Reference of parent class to child class object
  • View Object type: P.getclass (). GetName ()

  • class : Default/public default
  • final: Cannot overwrite before method, cannot be inherited before class
  • interface : interface; implementation: Implements
  • Exception :
  • Run-time exception
  • Check exception: Forced processing at compile time
  • Thrown by exception: throw
  • Throw multiple exceptions in the method: throws
  • Custom exception: Inherit exception
  • Nullpointexception: null pointer exception
  • Array index out of Bounds exception array bounds exception
  • Arith Meticexception Mathematical Operation Anomaly
  • code block : Part of a construction method
  • Static code blocks: classes are loaded only once
  • Instanceof type detection is not strict
  • Final constant capital + mate static saves memory
  • Memory
  • 1, the value of the basic data type is stored in the stack memory
  • 2. A reference to a local variable whose value is the address of the heap memory
  • The value of the property of the object, which is present in the heap memory
  • 3, = = Compare the value in the stack memory


Javase Tip 2

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.