, the current thread waits for wait (long timeout, int nanos ): the current thread waits until another thread calls the notify () or notifyAll () method of this object, or another thread breaks the current thread, or exceeds the actual time.
I. equals (): (important)
Class Man {private int age = 3; Man (int age) {this. age = age ;}} class Son {}public class Main {public static void main (String [] args) {Man BLF = new Man (20 ); man BLF1 = new Man
JAVA 16th (internal classes and their features)Internal class:An internal class is a class defined in a class, and the class defined in the class is called an internal class.I. Access features:Internal classes can directly access members of external classes, including private members.To access members of an internal class, an external class must be created.
Simple embodiment:
import out.in;class out{private int num = 3;class in{public void showou(){System.out.println(num);}}public void showin(
interface are implementation relations (implements)/** the interface cannot be instantiated * It can only be a subclass that implements the interface, it can only be instantiated after it overwrites all the abstract methods in the interface * otherwise, this subclass is only an abstract class **/class Demo1_Imple implements Demo // after a class implements the interface, the implements interface {public void show () {System. out. println ("show print" + num);} public void show1 () {System. out.
class Main {public static void main (String [] args) {Person BLF = new Person (); cin = new partition (System. in); // BLF. name = cin. nextLine (); BLF. name = "BLF2"; BLF. show (); System. out. println (Person. country); // static sharing, which can be output directly using the class name // but cannot be abused. So
amount of time Nanos): Causes the current thread to wait until another thread calls this object's notify () or Notifyall () method, or if another thread interrupts the current thread, or has exceeded an actual amount of timeOne, Equals (): (Key to Master)class Man{private int age = 3; Man (int.) {this.age = age;}} Class Son{}public class Main{public static void Main (string[] args) {Man BLF = new Mans (20); Man BLF1 = new Mans (20); Man BLF2 = BLF1;
Inner class:An inner class is a class defined in a class, and a class defined in a class is called an inner class.First, the characteristics of the visit:Inner classes can access members of external classes directly, including private membersExternal class to access members of an inner class, you must create an object of the inner classSimple embodiment:Import out.in;class out{private int num = 3;class in{public void Showou () {System.out.println (num);}} public void Showin () {In
beginning to end: the cat object will be transformed into an animal, and the cat object will be transformed into a catPS: Transition is purposefulExercise:
/** BLF and BLF2 story * BLF2 is the son of BLF **/class BLF {void function () {System. out. println ("write a program in C ++");} void speaks English () {System. out. println ("hello, world") ;}} class BL
into an animal, and the cat object will be transformed into a catPS: Transition is purposefulExercise:
/** BLF and BLF2 story * BLF2 is the son of BLF **/class BLF {void function () {System. out. println ("write a program in C ++");} void speaks English () {System. out. println ("hello, world") ;}} class BLF2 extends BLF
key words:this keywordThis uses one :Explain directly in code:Class Man{private int age;private String name; Man () {name= null;age = 0;} Man (String N)//Normal Direct print "blf,0", but change N to name, it will print null,0{name = n; } Changed to name although added to the reading, but the parameter name in the stack, the stack has a local variable name name, then the assignment of name, will only assign themselves to t
(); */animal a = new Cat ();//automatic type promotion, cat object lifted to animal, similar to byte x = 3;int y = x;a.sing ();//ps: Once the cat has been lifted to the animal, its unique features are inaccessible. Professional parlance, upward transformation. Purpose: Restrict access to unique features//if the cat's unique features are also available//You can move the object down, the cat C = (cat) a;//The animal A, down to the Cat Cc.fun ();//Downward transformation purposes: is to use a meth
JAVA 11th (inheritance)Inheritance: (extends)Many classes, but some members are repeated. To provide reusability, duplicate code is extracted, and inheritance is applied.1. Improved code reusability
2. Relationship between classes,Inheritance provides the premise for polymorphism, and there is no polymorphism without inheritance.
Class MAN {String name; int age;} class student extends MAN // MAN is the base class of student, and student is the subclass of MAN {void study () {System. out. print
JAVA learning lesson 11th (inheritance), java learning inheritanceInheritance: (extends)Many classes, but some members are repeated. To provide reusability, duplicate code is extracted, and inheritance is applied.1. Improved code reusability
2. Relationship between classes,Inheritance provides the premise for polymorphism, and there is no polymorphism without inheritance.
Class MAN {String name; int age;} class student extends MAN // MAN is the base class of student, and student is the subclas
Reprint: https://www.cnblogs.com/weiqinl/p/9049745.htmlThere are two ways to compare JavaScript: the strict comparison operator and the conversion type comparison operator.Corresponds === , and, in the equality operator !== == != .Give me a chestnut first.var str=' 1 'var NUM0=0var num1=1var BlT=Truevar BlF=Falsevar nul=NullVar und=UndefinedConsole.Log (str= = NUM1)TrueConsole.Log (str= = BlT)TrueConsole.Log (BlT= = NUM1)TrueConsole.Log (
cannot be instantiated * only by subclasses that implement the interface, and all abstract methods in the interface can be instantiated only after it has been overridden * Otherwise, this subclass is just an abstract class * */class demo1_ Imple implements demo//a class implements an interface, it must overwrite all the methods in the interface to implement the class implements interface {public void Show () {System.out.println ("show print" +num) ;} public void Show1 () {System.out.println ("S
JAVA 26th (multithreading (5)-communication between multiple threads, java Multithreading
1. Inter-thread Communication
Instance code:
Requirement: input a name and gender, and output a name and gender.
Class Resource {String name; String sex;} class Input implements Runnable {Resource r; Input (Resource r) {this. r = r;} public void run () {int x = 0; while (true) {synchronized (r) {if (x = 0) {r. name = "BLF"; r. sex = "male";} else {r. name = "N
the use of Neural network training function newff in the new MATLAB
I. Introduction of the New NEWFF
Syntax
· NET = NEWFF (p,t,[s1 S2 ... S (n-l)],{tf1 TF2 ... TFNL}, BTF,BLF,PF,IPF,OPF,DDF)
Description
NEWFF (p,t,[s1 S2 ... S (n-l)],{tf1 TF2 ... TFNL}, BTF,BLF,PF,IPF,OPF,DDF) takes several arguments
P
R x Q1 matrix of Q1 sample r-element input vectors
T
SN x Q2 matrix of Q2
keyword two, staticCharacteristics:Static used to decorate members (member functions and member functions)The presence of static, which takes precedence over the existence of the object, loads as the class loadsStatic modified member, shared by all objectsStatic can be called directly by the class name, format: System.out.println (person.country);: class name. static memberUse detailsStatic methods can only access static members, which are members of static adornments, static int data;A static m
One, the communication between the threadsInstance code:Requirement is: After entering a name and gender, a name and gender will be outputclass resource{string name; String sex;} Class Input implements Runnable{resource R;input (Resource r) {THIS.R = R;} public void Run () {int x = 0;while (True) {synchronized (R) {if (x==0) {r.name = "BLF"; r.sex = "Male";} else {r.name = "Nininini"; r.sex = "female";} x = (++x)%2;}}} Class output implements Runnable
constructor.For example, when an object is created, it has a default age and name.
Sample Code:
Class man {private int age; private String name; man () // defines a man class constructor {age = 20; name = "john" ;}public void fun () {System. out. println (name + "" + age) ;}} public class Main {public static void main (String [] args) {man jo = new man (); jo. fun ();}}
Reload the constructor:
Class man {private int age; private String name; man () // defines a man class constructor -------
= new Man (); Jo.fun (); Man JJ = new Man (1, "BLF"); Jj.fun ( ); Man jjj = new Man ("BLF2"); Jj.fun ();//print BLF 0}} PS: A class in which the name of the function with the same name must be overloaded.If a constructor is not called when an object is created, it means that the creation failed.The memory allocation diagram for the constructor (as): Object to go into the heap, function to go into the stack
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.