1.java It's interpreted language .java The virtual machine can compile and run many times at a time .

2.JDK(java software Development kit  Software development package ),JRE(java Runtime Environment java Running environment ).

3.javac compile java Program ,java function java Program .

4. A file can have at most one public class.

5.java in switch Statement can only detect int Type values (JDK1.6 before ).

6. stay java One byte in is eight bits , A character takes up two bytes (16 position unicode character string ).

7. In the memory byte Occupy 1 Bytes ,int Occupy 4 Bytes ,long Type account 8 Bytes ;float Occupy 4 Bytes ,double Occupy 8 Bytes ;boolean Type account 1 Bytes ;

8.java No overloading of operators is provided .

9. stay static Cannot access non in method static Members of .static The method is to add... Before the function static qualifiers , Such as :public static vooid main(String args[]);public static void print();

10. It's a convention to package Name your company's domain name upside down , Then follow the project name . Such as :cn.edu.jxau.Game24.

11. The default access rights are default.

12. Interfaces can be inherited from each other , Classes can be inherited from each other , But the interface between class and interface can only be realized by class . A class can only inherit one parent class , But you can implement multiple interfaces .

13. Array

The form of a one-dimensional array :

(1),  int a[]; a = new int[5];   Equate to int a[] = new int[5];
(2),  int[] a; a = new int[5];   Equate to   int[] a = new int[5];
The form of a two-dimensional array :

int a[][] = {{1,2}, {3,4,5,6}, {7,8,9}}; A two-dimensional array can be regarded as an array of elements .
 java The declaration and initialization of multi-dimensional array should be in the order from high dimension to low dimension , Such as :
Method (1)
int a[][] = new int[3][];

    a[0] = new int[2];

    a[1] = new int[4];

    a[2] = new int[3];// correct

   int t[][] = new int[][4];// illegal

Method (2);
 int a[][] = new int[3][5];// correct , Assign a two-dimensional array of three rows and five columns .

Study C and C++ It's easy to make mistakes

14. Enhanced for loop
  advantage : Enhanced for Loop for traversal array and collection It's quite easy to use . for example :

import java.util.*;

public class EnhancedFor {

public static void main(String args[]) {

int arr[] = {1,2,3,4,5};

for(int i:arr) {



Collection c = new ArrayList();

c.add(new String("sss") );

c.add(new String("aaa") );

c.add(new String("bbb") );

for(Object o:c)




shortcoming : Array , Cannot easily access subscript values ;

summary : In addition to simply traversing and reading the contents , The use of enhanced for loop .

15. Generic
 JKD1.4 Before the type was not clear :
  The type that loads the collection is treated as Object treat , And lose your real type ; Transformation is often required when fetching from a collection , Low efficiency , It's easy to make mistakes .
  terms of settlement :
  When defining a collection, define the type of the collection at the same time ;
  Can be defined in Collection When it's time to specify ;
  It can also be used in circulation Iterator Appoint .
  benefits :
  Enhance the readability and stability of the program .

16. Basic concept of thread :
(1), A thread is a sequence control flow within a program .
(2), The difference between threads and processes :
Each process has its own code and data space ( Process context ), There is a big overhead in switching between processes ;
Threads can be thought of as lightweight processes , The same class of threads share code and data space , Each thread has its own running stack and program timer (pc), Low cost of thread switching ;
Multi process : Multiple tasks can be run simultaneously in the operating system ( Program );
Multithreading : Multiple sequential flows execute simultaneously in the same application ;

17. Implementation of threads

Java The thread of java.lang.Thread Class to achieve .VM At startup, there will be a main method (public static void main(){} ) Thread defined . Can be created by Thread To create a new thread . Each thread passes through a specific Thread Object method run() To complete its operation , Method run() Is the thread body . By calling Thread Class start() Method to start a thread .

18. When you can use an interface, don't start from Thread Class inheritance , Because not only can interface methods be implemented with interfaces , And you can inherit other classes .

19.Sleep Method :Thread Static method of (public static void sleep (long millis) throws InterruptedException)  Hibernate the current thread ( To suspend execution millis millisecond );
Join Method : Merge a thread ;
Yield Method : Give up CPU, Give other threads the opportunity to execute .

20.synchronized (this) : Lock the current object , When executing the current object, other threads are not allowed to interrupt the insertion . The ways to use it are :

class Timer {

private static int num = 0;

public synchronized void add(String name) {

// Lock the current object during the execution of this method .

num ++;

try {


catch( InterruptedException e) {



System.out.println(name + ", You are the first " + num +" Use Timer The thread of .");




class Timer {

private static int num = 0;

public  void add(String name) {

synchronized(this) {  // Lock the code snippet in the brace area

num ++;

try {


catch( InterruptedException e) {



System.out.println(name + ", You are the first " + num +" Use Timer The thread of .");


21.wait(); Use wait() The premise is to use synchronized Lock in the method .notify The function of the is to wake up other threads ,notifyAll The role of the is to wake up many other threads .

22.wait Methods and sleep Differences in methods :
(1),wait The method is Object Class method ,sleep The method is Thread Class method .
(2),wait when , Other threads can access locked objects ; call wait Method must lock the object .
(3),sleep when , No other thread can access the locked object .

Java Notes More articles about

  1. Java Notes 00 - Singleton Pattern( Single example summary )

    turn :http://hukai.me/java-notes-singleton-pattern/ I won't go into the concept of singleton pattern here , Direct demonstration of several different implementations . 0)Eager initialization ...

  2. Example is given to illustrate Java Medium null

    interpreter : Anchor Translation time : 2013 year 11 month 11 Japan Link to the original text : What exactly is null in Java? Let's look at the following sentence first : String x = null; 1. This statement ...

  3. Write high quality code to improve java programmatic 151 A suggestion ——[1-3] Basics ? It's also the foundation

    Original address :   http://www.cnblogs.com/Alandre/  ( Mud, brick, tile, pulp, carpenter ), What needs to be reprinted , Keep it ! Thanks The reasonable man adapts himse ...

  4. Example is given to illustrate Java Medium null( turn )

    Let's look at the following sentence first : String x = null; 1. What exactly does this statement do ?  Let's review what variables are , What are variable values . A common metaphor is Variable is equivalent to a box . It's like using boxes to store things ...

  5. Java Class notes ( 3、 ... and ): Abstract classes and interfaces

    In the article object oriented , We said that one function of polymorphism is to “ What do you do ” and “ How do you do it? ” Separate from , The method used is to put different concrete implementations in different subclasses , Then pass in a reference to the parent object... To the interface . The content of this blog is interface ( here &qu ...

  6. CM12.1/13.0 Compilation tutorial

    Environment building 1. install 64 position Ubuntu System ( Physical installation . Virtual machine installation is available ) Be careful : The machine is required to at least 4G Memory ( Virtual machines allocate at least 4G Memory ), Hard disk at least 100G Space ( Source code 20G+, After compiling, the whole directory is about 60~70G) Installation method ...

  7. Spark case analysis

    One . demand : Calculate the top three page views import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...

  8. A Java back-end engineer's study notes

    loveincode's notes Study some records of work , Collection . A popular link library Basic computer notes operating system , Compiler principle , computer network , Internet Protocol ... Common data structures and algorithms Java real ...

  9. [Java coding] leetcode notes

    1, How to find the maximum without sorting , The next largest or the smallest ? var int max1, max2, min1; iterate array once: update max1, max2, min1, for ex ...

Random recommendation

  1. Oracle Basic operation summary

    --10g New table space type : A large file (Bigfile) Table space .--10g When the database is created , The default table space type is specified . If not specified , The default is SMALLFILE Type of tablespace .SELECT * ...

  2. Android custom View AirConditionerView hacking

    package com.example.arc.view; import android.content.Context; import android.graphics.Canvas; import ...

  3. Once a day LeetCode--141.Linked List Cycle( The problem of linked list links )

    Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using ext ...

  4. SQL date ( turn )

    Usually , You need to get the current date and calculate some other dates , for example , Your program may need to judge the first or last day of a month . Most of you probably know how to split dates ( year . month . Day, etc. ), And then just use the split years . month . Day and so on in a few ...

  5. entrust 、Lambda expression

    This article is from :http://wenku.baidu.com/link?url=o9Xacr4tYocCPhivayRQXfIc9kOZeWBwPn2FZfeF19P4-8YX5CMXs74WB-Y8t0S ...

  6. Massive data import , terms of settlement , Practice from timing from sqlserver Batch sync data to mySql

    c# Code , Batch import data code public class MySql_Target : ZFCommon.DataAccesser.Base.DABase { public MySql_Target() ...

  7. 『NOIP2018 Popularization group 』

    Headline Statistics Title Description Kaikai has just written a wonderful composition , How many characters are there in the title of this composition ? Be careful : The title may contain large . Small letters . Numeric character . Spaces and line breaks . Statistics title words Symbol time , Spaces and line breaks are not counted . Input format ...

  8. MYSQL Optimize common methods ( Reprint )

    1. Select the most appropriate field properties  MySQL It can support large amount of data access , But generally speaking , The smaller the table in the database , The faster queries are executed on it . therefore , When creating tables , For better performance , We can set the width of the fields in the table as wide as possible ...

  9. L146 Space Station Hole Cause Will Be Determined

    The head of the U.S. space agency said Tuesday he's sure that investigators will determine the cause ...

  10. stylus , another css processor

    1. install from npm sudo npm install stylus 2. create a styl file named step1.styl border-radius() { ...