9 / 22-9 / 28 java learning summary (classroom and after-school learning summary) & Experiment Summary 3

 

 

Third experiment String application class

  • Purpose
  • Master the use of class String class;
  • Learn to use JDK help documentation;
  • Content Experiments

1. Known string: "this is a test of java" required to do the following requirements :( source code, the results screenshot).

  • The number of letters in the string s occurs statistics.
  • The string neutron count the number of times the string "is" appears.
  • The number of words in the string "is" appears in the statistics.
  • Achieve reverse the string is output.

 

 

 

 

2. Write a program, using the following algorithm to encrypt or decrypt the English string input by the user. It requires source code, the results screenshot.

 

 3. Given the string "ddejidsEFALDFfnef2357 3ed". The output string in the number of capital letters, lowercase letters count, the number of non-English letters.

 

 

 

 

 

 

 

 

Classroom and after-school learning summary

 

inherit

Inheritance is the subclass inherits the characteristics and behavior of the parent class, so that the subclass object (instance) instance fields and methods having a parent class or subclass inherits methods from parent classes, subclasses that have the same parent class behavior. Inheritance can also be single inheritance multiple inheritance

 

 Inherited characteristics:
1. only supports single inheritance, that is a subclass allows only one parent.
2. subclass can have attributes and methods of the parent class
3. subclass can have its own properties and methods
4. subclasses can override the parent class of cover

 

Inherited category

  1. Sort by category - implement sorting
  2. Reverse class - for data storage Reverse

 

Precautions

  1. Can inherit public and protected member variables of the parent class; you can not inherit private member variable of the parent class
  2. Access to member variables of time and only subclasses can inherit the parent class in the same package
  3. Subclass can not inherit the parent class constructor

 

This keyword super keyword (repeat)

This key role of

(1) If the member variable and a local variable with the same name exist, the default method is within the local variables of this keyword data specified by the access member variables;

(2) In a constructor may call another function to initialize the object structure;

 

Super action keywords

(1) the parent sub-members with the same name exist (including variables and methods), in subclasses default access subclass members, the members can access the super keyword specified parent class;

(2) create a sub-class object, the default constructor will first call the superclass no-argument can be constructed by super parent class keyword specifies the call.

 

the difference

1. The representative of inconsistent things.

super keyword can not represent the object, but represents an object in a memory.

this keyword represents the object belongs to the caller function.

2. Use the premise inconsistent.

super keyword must have to use inheritance.

this keyword does not require the presence of inheritance can also be used

3. Call the difference constructor:

 Keywords are super constructor calls the parent class.

this keyword is to call this class constructor.

 

Precautions 

super keyword and this can not occur at the same time calling other constructors in the same constructor. Because the first two statements require a statement. (Examples main method can not use this, super)

 

 

Final Keyword

With the final declaration class methods are not subclasses, subclasses declared not overwritten, the variable declaration is constant can not be modified.

 

 

Abstract class

1.Java all objects are described by type, but not all of the classes are used to describe an object, if a class does not contain enough information to describe a specific target, such a class is abstract class. Other functions remain abstract classes, but can not instantiate the object. Since the abstract class can not be instantiated objects, abstract class must be inherited, can be used.

2.Java abstract class represents is an inheritance, a class can only inherit an abstract class, but a class can implement multiple interfaces.

 

 

 

StringBuffer are two ways to initialize objects

reverse method (inversion StringBuffer object content, then a new string)

setCharAt method (modified object position index value index new character character ch)

 

 

 

summarize

This week a student of inheritance, all are built around the concept of inheritance to this, one aspect of this school feel okay (after all, but also see their net lesson), is still afraid to use other knowledge when the integrated time back out problem.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/lpf666/p/11601034.html