Home > Java > javaTutorial > body text

Java learning experience sharing

巴扎黑
Release: 2017-07-21 14:16:45
Original
1654 people have browsed it

Programming Thoughts

  • API documentation is very important! ! !

  • While thinking and writing, I will have a lot of ideas.

  • Frequently printing something is very helpful for debugging the program.

  • Check the API documentation more, type the code more, and type after you understand it.

  • Memorizing is a good way to study with high intensity in a short period of time.

  • Keep the example program well. If you need to use it in the future, check the API and write it according to the writing method of the example program.

  • Three points support your development: technology, management and communication.


  1. In this question, what are the classes and objects

  2. What properties should the classes and objects have and methods

  3. What is the relationship between classes and classes

Create methods

  1. Methods Name

  2. Parameters of method

  3. Return value of method

Memory

Understand how memory, stack, heap, data seg, and code run

Package and import

package com.bjsxt.java140;//1. The company’s domain name is reversed Come over, followed by the project name, etc.
public class Cat {
}

public class Dog {
public static void main(String[] args) {
com.bjsxt.java140.Cat c = new com.bjsxt.java140.Cat();//2. The compiled class must be located in the correct directory
}
}

import com.bjsxt.java140.Cat; //3. Import package
public class Dog {
public static void main(String[] args) {
Cat c = new Cat() ;//4. Abbreviation
}
}
***

Override (override/overwrite)

When rewriting the method, copy, do not type the wrong method name.

Inheritance

  1. private

  2. default

  3. protected

  4. public

class can only be a constructor in public and default

inheritance

  • During the construction process of the subclassmustcall the construction method of the parent class once

  • The subclass uses super(arguments list) in its own construction method to call the parent class Constructor method

  • Use this(arguments list) to call other constructor methods of this class

  • If super is called, it must be written in the subclass The first line of the construction method

Polymorphism (polymophysm)

Three necessary conditions for the existence of polymorphism:

  1. There must be inheritance

  2. There must be overriding

  3. The parent class reference points to the child class object

Exception handling (errors that occur during runtime)

It is important to observe the name and line number of the error
Alt text

  • Be able to handle it Those that cannot be processed must be thrown (throws Exception)

  • 5 Keywords: try, catch, finally, throws, throw

  • Catch the small one first, then the big one

  • Rewrite method, The exceptions thrown must be consistent or not thrown

  • Array

  • Allocate space first, then load the array

int a[ ];/ /Declare the name of the array

a = new int[3];//Allocate space

a[0] = 1; a[2] = 5;a[3] = 7;
date days[ ];//Declare the array name

days = new date[3];//Allocate space
days[0] = new date(1, 4, 2017);
days[1] = new date (2, 4, 2017);
days[2] = new date(3, 4, 2017);


Container

Generic


When defining a collection, define the type of objects in the collection at the same time
  • Generic➕ Automatic packaging and unboxing (auto-boxing&unboxing) can omit forced conversion

  • IO

Input stream

  1. Output stream

  2. Byte stream

  3. Character stream

  4. Node stream

  5. Processing flow

  6. Thread

  7. Definition: different execution paths in a program.

Process is a static concept, and threads are actually running in the machine.

  • At the same point in time, a CPU can only support one thread executing.

  • If you can use the interface, don't inherit from the Thread class. This will be more flexible.

  • synchronized, when this method is executed, the current object is locked.

  • network programming

The above is the detailed content of Java learning experience sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template