- Static indicates that main () can still run without creating a class object.
- Java programs are made up of classes.
- The file name of the original program cannot be arbitrarily named, it must be the same as the public class name, so in a separate primitive program, there is only one public class, but there can be many non-public classes.
- Data type
- Byte:1 byte
- Short:2 bytes
- Int:4 bytes
- Long:8 bytes
- Float:4bytes
- Double:8 bytes
- Char:2 bytes
- Boolean
- Operator
- Assignment operator: =
- Unary operators: + 、-、! , ~
- Arithmetic operators: + 、-、 *,/,%
- Relational operators:
- Increment decrement operator
- Logical operators:&&, | |
- Parentheses operator: ()
- Array:
- Declaration of one-dimensional array: int socre[]; Score = new Int[3];
- Array copy: System.arraycopy (source,0,dest,0,x)
- Array sort: Arrays.sort () (Import java.util.*)
- Declaration of a two-dimensional array: int score[][] = {{},{},{}};
- Class
- Object declaration: Class Name Object name = new class name ();
- Comparison of objects:
- = =: Used to compare memory address values of two objects for equality
- Equals (): Used to compare the consistency of the contents of two objects
- Object array: Person p[]; p = new Person[3];
- Final keyword
- The final tagged class cannot be inherited
- Final tagged methods cannot be overridden by a quilt class
- A variable of the final tag is a constant and can only be assigned once
- Static keyword
- static variables
- Static methods
- instanceof Keywords
- Determines whether a class implements an interface, or whether an instance object belongs to a class.
- Java Common class libraries
- String class and StringBuffer class
- System class and Runtime class
- Package and access rights
- Package Statement: Package Name.java
- Package Imports: Import Package name. Class names
- JDK Common Packages
- Java.lang contains some of the core classes of the Java language, such as String, Math, Integer, System, and thread.
- java.awt contains multiple classes that make up an abstract window toolset for building and managing the application's graphical user interface (GUI)
- Avax.swing is used to build a graphical user interface, which is a lightweight component relative to the java.awt package.
- Java.applet
- The java.net contains the operation classes that perform network-related operations.
- java.io classes that provide multiple input/output functions.
- Java.util contains some utility classes.
- Access control permissions for class members
- Private: The member method or member variable can only be used inside this class.
- Default: Access control members can be accessed by other classes in this package.
- Protected: This member can be accessed either by another class in the same package or by a subclass in a different package
- Public: can be accessed by all classes, regardless of whether the access class is within the same package as the class being accessed.
|
Private |
Default |
Protected |
Public |
Same class |
√ |
√ |
√ |
√ |
Classes in the same package |
|
√ |
√ |
√ |
Subclasses in different packages |
|
|
√ |
√ |
In the other package |
|
|
|
√ |
- Java Naming conventions
- The letters in the package name are all lowercase
- Class name, interface name should use nouns, capitalize each word first letter
- Variable name the first word lowercase, followed by the first letter of each word capitalized
- The first word of the method name is lowercase and the first letter of each word is capitalized
- Every letter in a constant name is capitalized
- File IO operations
- File class: The file class is the only object in the IO package that represents the disk file itself.
- GetName () returns the file name
- GetParent () returns the parent directory name
- Exists () file exists
- Randomaccessfile class
- Stream class
- Inputstream,outputstream,fileinputstream, FileOutputStream: Byte stream Class (processing bytes or binary objects)
- Reader,writer, FileReader, FileWriter: Character Stream Class (handles characters or strings)
- Pipe flow: PipedInputStream, PipedOutputStream, Pipedreader, PipedWriter
- Print Flow: system.in, System.out
- Redirection and piping
- % Java Average < data.txt//redirecting from a file to standard input
- % java randomseq 200.0 > data.txt//redirecting Standard output to a file
- % java RANDOMSEQ 1000 200.0 | Java Average//piping The output of one program to the input of another
"2014-11-17" Java Learning note