"2014-11-17" Java Learning note

Source: Internet
Author: User
Tags arithmetic operators array sort logical operators

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

"2014-11-17" Java Learning note

Related Article

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.