Java and Scala learning diary 1, javascala Diary

Source: Internet
Author: User
Tags bitset bitwise operators map class scala tutorial

Java and Scala learning diary 1, javascala Diary

1. Scala Data Type

(1) Byte: an 8-Bit Signed complement integer. The range is-128 to 127.

(2) Short: A 16-Bit Signed complement integer. The range is-32768 to 32767.

(3) Int: 32-Bit Signed complement integer. The range is-2147483648 to 2147483647.

(4) Long: A 64-Bit Signed complement integer. The range is-9223372036854775808 to 9223372036854775807.

(5) Float: 32-bit IEEE754 Single-precision floating point number.

(6) Double: 64-bit IEEE754 Single-precision floating point number.

(7) Char: A 16-bit unsigned Unicode character with a range of U + 0000 to U + FFFF.

(8) String: Character Sequence.

(9) Boolean: true or false.

(10) Unit: indicates no value, which is equivalent to void in other languages. Used as the result type that does not return any result method. Unit has only one instance value and is written ().

(11) Null: null or Null reference.

(12) Nothing: The Nothing type is at the lowest end of the Scala class level. It is a child type of any other type.

(13) Any: Any is the superclass of all other classes.

(14) AnyRef: The AnyRef class is the base of all reference classes in Scala.


2. Scala access modifier

Scala access modifiers include private, protected, and public, as shown below:

(1) private

In Java, external classes are allowed to access private members of internal classes, but in Scala, external classes are not allowed to access private members of internal classes.

(2) protected

In Java, class subclasses and class access protection members in the same package are allowed, but in Scala, only class subclasses are allowed to access protection members.

(3) public

If no modifier is specified, Scala is public by default.

(4) Scope Protection

Private [x] indicates "This member is not only for […] Or […] Classes in the package and their associated objects are visible, and are private to all other classes.

It must be noted that x can refer to a specific package, class, or singleton object.

Note: Scala operators include Arithmetic Operators, Relational operators, logical operators, bitwise operators, and value assignment operators.


3. Java Data Structure

Resolution:

(1) Enumeration: The Enumeration interface itself does not belong to the data structure, but it defines a way to retrieve continuous elements from the data structure.

(2) BitSet: A Bitset class creates a special type of array to save the bit value. The array size in BitSet increases as needed.

(3) Vector: this class is very similar to ArrayList, but this class is synchronous and can be used in multi-thread scenarios. This class allows you to set the default length of growth, the default expansion method is twice the original one.

(4) Stack: A Stack is a sub-class of Vector, which implements a standard Stack of first-in-first-out.

(5) Dictionary: The Dictionary class is an abstract class used to store key/value pairs. Its function is similar to that of the Map class.

(6) hash table (Hashtable): Hashtable is a subclass of the Dictionary class and is located in the java. util package.

(7) Properties: Properties inherits from Hashtable, indicating a persistent property set. Each key in the property list and its corresponding values are a string.


4. Java Multithreading

Resolution:

(1) When the Runnable and Callable interfaces are implemented to create multiple threads, the thread class only implements the Runnable interface or Callable interface and can inherit other classes.

(2) when using the method that inherits the Thread class to create multiple threads, the compilation is simple. If you need to access the current Thread, you do not need to use

Thread. currentThread () method. Use this to obtain the current Thread.


5. javadoc tag

Resolution:

(1) @ author: identify the author of a class: @ author description

(2) @ deprecated: indicates an expired class or member: @ deprecated description

(3) {@ docRoot}: Specifies the Path of the root Directory of the current document: Directory Path

(4) @ exception: indicates the exception thrown by a Class: @ exception-name explanation

(5) {@ inheritDoc}: Notes inherited from the direct parent class: Inherits a comment from the immediate surperclass.

(6) {@ link}: Insert a link to another topic: {@ link name text}

(7) {@ linkplain}: Insert a link to another topic, but the link is displayed in plain text: Inserts an in-line link to another topic.

(8) @ param: Describes the parameter of a method: @ param parameter-name explanation

(9) @ return: return Value Type: @ return explanation

(10) @ see: Specifies the link from one topic to another: @ see anchor

(11) @ serial: indicates a serialization attribute: @ serial description

(12) @ serialData: describes the data written using the writeObject () and writeExternal () Methods: @ serialData description

(13) @ serialField: Specifies an ObjectStreamField component: @ serialField name type description

(14) @ since: Mark when a specific change is introduced: @ since release

(15) @ throws: same as The @ exception tag: the @ throws tag has the same meaning as The @ exception tag.

(16) {@ value}: Displays the constant value. the constant must have the static attribute: Displays the value of a constant, which must be a static field.

(17) @ version: version of the specified class: @ version info


6. import java. util. {HashMap => _,_}

Resolution: All util package members are introduced, but HashMap is hidden.

Note: by default, Scala always introduces java. lang. _, scala. _, and Predef ._.


7. Scala Collection

Resolution:

(1) Scala List: the feature of List is that its elements are stored linearly, and repeated objects can be stored in the collection.

(2) Scala Set: Set is the simplest Set. Objects in the set are not sorted in a specific way and there are no repeated objects.

(3) Scala Map: Map is a set that maps key objects and value objects. Each element of it contains a pair of key objects and value objects.

(4) Scala tuples: tuples are a set of different types of values.

(5) Scala Option: Option [T] indicates a container that may contain values or does not contain values.

(6) Scala Iterator (Iterator): The Iterator is not a container, but more specifically a method to access elements in the container one by one.


8. ScalaNLP, Breeze, Epic, Puck

Resolution:

(1) ScalaNLP: a suite of machine learning and numerical computing libraries.

(2) Breeze: a set of libraries for machine learning and numerical computing.

(3) Epic: a high-performance statistical parser and structured prediction library.

(4) Puck: an insanely fast GPU-powered parser, built on the same grammars produced by Berkeley Parser.


9. Breeze

Resolution:

(1) breeze-math: Numerics and Linear Algebra. Fast linear algebra backed by native libraries (via JBlas) where appropriate.

(2) breeze-process: Tools for tokenizing, processing, and massaging data, especially textual data. SPS stemmers, tokenizers, and stop word filtering, among other features.

(3) breeze-learns: Optimization and Machine Learning. Contains state-of-the-art routines for convex optimization, sampling distributions, several classifiers, and DSLs for Linear Programming and Belief Propagation.

(4) breeze-viz: (Very alpha) Basic support for plotting, using JFreeChart.


10. Fernflower

Analysis: a powerful tool for decompilation and Analysis of Java programs.


11. Object-oriented Behavior Features

Resolution:

(1) inheritance is an important means for implementing software reuse of object-oriented systems. When a subclass inherits its parent class, as a special parent class, it will directly obtain the attributes and methods of the parent class;

(2) Encapsulation means hiding the implementation details of an object and exposing its functions through some common methods;

(3) polymorphism means that the subclass object can be directly assigned to the parent class variable, but it still shows the behavior characteristics of the subclass at runtime, this means that objects of the same type may show different behavior characteristics at runtime.


12. UML diagram

Analysis: UML diagrams can be divided into static and dynamic diagrams. UML 2.0 includes 13 types of diagrams, as shown below:

(1) Static Graph

Use case digraphs, class digraphs, package digraphs, and component Graphs

Divisor), object divisor, deployment divisor, and composite structure divisor ).

(2) Dynamic Graph

Activity digraphs, communication digraphs, interactive overview digraphs, sequence digraphs, and state machine digraphs) timing digrams ).

Note: commonly used UML diagrams include the use case diagram, class diagram, component diagram, deployment diagram, sequence diagram, activity diagram, and state machine diagram.


13. use case diagram [2]

Resolution: A Use Case chart is a view that describes system functions that consists of actors, Use cases, boundaries, and relationships.


14. Class Diagram

Resolution: A class chart is described using a rectangle containing three parts. The top part shows the class name, the middle part includes the class attributes, and the bottom part contains the class method. Classes have three basic relationships: Association (aggregation and combination), generalization (inheritance), and dependency.

Note: Aggregation uses solid line representation with hollow diamond boxes, and combination uses solid line representation with solid diamond boxes. Generalized use of solid line representation with hollow arrows. Dependencies are represented by dotted lines with arrows.


15. Component Diagram

Resolution: The component diagram provides a physical view of the system. Its purpose is to display the dependency between the software in the system on other software components (such as library functions. A component chart can be displayed at a very high level, so that only coarse-grained components are displayed. It can also be displayed at the component package level.


16. Deployment Diagram

Resolution: The deployment diagram shows the physical architecture of software and hardware in the system. From the deployment diagram, you can understand the physical relationship between software and hardware components and the component distribution of processing nodes. The deployment diagram shows the structure of the runtime system and the configuration and deployment modes of the hardware and software elements that constitute the application.


17. Sequence Diagram

Resolution: The sequence diagram shows the detailed process of a specific use case, shows the call relationships between different objects in the process, and shows different calls to different objects in detail. The sequence diagram describes the interaction between objects, focusing on describing messages and their chronological order.


18. activity diagram

Parsing: describes the process of activities or methods in the use case. If you go out of the parallel activity description in the activity diagram, it becomes a flowchart.


19. State Machine Diagram

Resolution: describes the different States that need to be followed during the lifecycle of an object, and describes in detail the events that stimulate the state change of the object, and the actions taken when the object state changes.


20. Java bitwise operators

Resolution:

(1) &: bitwise AND.

(2) |: By bit or.

(3) ^: Non-bitwise.

(4) <: Left displacement operator.

(5) >>: right shift operator.

(6) >>>: unsigned right shift operator.


21. Java logical operators

Resolution:
(1) &: And. true is returned only when both the first and second operands are true. Otherwise, false is returned.

(2) &: Do not short-circuit and, the function is the same as &, but do not short-circuit.

(3) |: Or. If either of the two operands is true, true is returned. Otherwise, false is returned.

(4) |: Do not short circuit or, the function is the same as |, but not short circuit.

(5 )! : No. Only one operand is required. If the operand is true, false is returned. Otherwise, vice versa.

(6) ^: returns true if two operands are different, and false if the two operands are the same.


22. Method for variable Java parameter length

Resolution: After JDK 1.5, Java allows you to define parameters with variable length, so that you can specify an uncertain number of parameters for the method. If you add three points (...) after the last parameter type when defining a method (...), it indicates that this parameter can accept multiple parameter values, and multiple parameter values are passed as arrays.


23. Java Access Controller

Resolution:

(1) private access control permission: if a member (including attributes and methods) in the class is modified using the private access control operator, the member can only be accessed within the class. This access control operator is most suitable for modifying attributes. You can use it to modify attributes so that they can be hidden inside the class.

(2) default access control permission (package access permission): If a member (including attributes and methods) in the class or a top-level class does not use any access control operator modifier, it is called the default access control. The members or top-level classes of the default access control can be accessed by other classes under the same package.

(3) protected Access Control permission (subclass access permission): If a member (including attributes and methods) is modified using the protected access control operator, this member can be accessed by other classes in the same package or by sub-classes in different packages. If you use protected to modify a method, you usually want its subclass to override this method.

(4) public Access Control permission (public access permission): If a member (including attributes and methods) or a top-level class uses public modification, this member or top-level class can be accessed by all classes, regardless of whether the parent class or the parent class is in the same package or whether it has a parent-child inheritance relationship.


24. super reference of the Java parent class instance

Resolution: If you need to call the method of the instance whose parent class is overwritten in the subclass method, you can use super as the caller to call the method of the instance whose parent class is overwritten.


25. final keywords

Parsing: Java provides final keywords to modify variables, methods, and classes. The system does not allow the final variable to be assigned a value again, the subclass does not allow the final method of the parent class to be overwritten, and the final class cannot derive subclass. By using the final keyword, Java is allowed to implement immutable classes, which makes the system more secure.


References:

[1] Scala Tutorial: http://www.runoob.com/scala/scala-tutorial.html

[2] UML series diagram-use case diagram: http://www.cnblogs.com/Yogurshine/archive/2013/01/14/2859248.html

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.