1. Common objects (overview of scanner and method introduction)
2, common objects (scanner to get the data of small problems and solutions)
- A: Two common methods:
- public int nextint (): Gets a value of type int
- public string nextline (): Gets a value of type string
- B: Case Demo
- A: The case of getting multiple int values, multiple string values, is shown first
- B: The problem of getting the int value first and then getting the string value
- C: Problem Solving solution
- The first: Gets a string after a value is first obtained and a new keyboard entry object is created.
- The second is to get all the data first by string, then what you want, and what you convert to. (later)
3. Common objects (an overview of the String Class)
4. Common objects (method of constructing the string class)
- A: Common construction methods
- Public String (): Empty construct
- public string (byte[] bytes): Convert byte array to string
- public string (byte[] bytes,int index,int length): Turns a portion of a byte array into a string
- public string (char[] value): Convert character array to string
- public string (char[] Value,int index,int count): Turns a part of a character array into a string
- public string (string original): Convert string constant value to string
- B: Case Demo
- Demonstrates common construction methods of the String class
5. Common Objects (common interview questions for string class)
- 1. Determine if S1 and S2 defined as string are equal
- String s1 = "abc";
- String s2 = "abc";
- System.out.println (S1 = = s2);
- System.out.println (s1.equals (S2));
- 2. The following sentence creates several objects in memory?
- String s1 = new String ("abc");
- 3. Determine if S1 and S2 defined as string are equal
- string s1 = new String ("abc");
- String s2 = "abc";
- System.out.println (S1 = = s2);?
- System.out.println (s1.equals (S2));?
- 4. Determine if S1 and S2 defined as string are equal
- String s1 = "a" + "B" + "C";
- String s2 = "abc";
- System.out.println (S1 = = s2);?
- System.out.println (s1.equals (S2));?
- 5. Determine if S1 and S2 defined as string are equal
- String s1 = "AB";
- String s2 = "abc";
- String s3 = s1 + "C";
- System.out.println (s3 = = s2);
- System.out.println (s3.equals (S2));?
6. Common objects (the judging function of string class)
- The judgment function of A:string class
- Boolean equals (Object obj): Compares the contents of strings for the same, case-sensitive
- Boolean equalsignorecase (String str): Compares whether the contents of a string are the same, ignoring case
- Boolean contains (String str): Determines whether a large string contains a small string
- Boolean startsWith (String str): Determines whether a string begins with a specified string
- Boolean endsWith (String str): Determines whether a string ends with a specified string
- Boolean IsEmpty (): Determines whether the string is empty.
7. Common objects (impersonate user login)
- A: Case Demo
- Requirements: Simulate login, give three chances, and tip a few more times.
- User name and password are admin
8. Common objects (Get function of String class)
- A:string-Class Acquisition function
- int length (): Gets the length of the string.
- char charAt (int index): Gets the character at the specified index position
- int indexOf (int ch): Returns the index at the first occurrence of the specified character in this string.
- int indexOf (String str): Returns the index of the first occurrence of the specified string in this string.
- int indexOf (int ch,int fromIndex): Returns the index at the first occurrence of the specified character from the specified position in this string.
- int indexOf (String str,int fromIndex): Returns the index at the first occurrence of the specified string from the specified position in this string.
- LastIndexOf
- string substring (int start): Intercepts the string starting at the specified position, at the end of the default.
- string substring (int start,int end): Intercepts the string from the specified position to the specified position.
9. Common objects (traversal of strings)
- A: Case Demo
- Requirements: Traversing strings
10_ Common objects (count different types of characters)
- A: Case Demo
- Requirements: Counts the number of uppercase and lowercase alphabetic characters, number of occurrences of numeric characters, and occurrences of other characters in a string.
- [Email protected]#$%^
11. Common Objects (conversion function of String class)
12. Common objects (convert characters as required) (chained programming)
- A: Case Demo
- Requirement: The first letter of a string is capitalized and the remainder is lowercase. (only English uppercase and lowercase characters are considered)
13. Common objects (turn arrays into strings)
- A: Case Demo
- Requirement: To stitch the data in an array into a string in a specified format
14. Common objects (other functions of the String Class)
- A:string replacement function and case demonstration
- String replace (char Old,char new)
- String Replace (string old,string new)
- B:string to remove the string two spaces and the case demonstration
- C:string comparison of two strings in dictionary order and demonstration of a case
- int CompareTo (String str) (temporarily not available)
- int comparetoignorecase (String str) (Learn)
15. Common objects (string inversion)
- A: Case Demo
- Requirements: Reverse the string
- Example: Keyboard entry "ABC"
- Output result: "CBA"
16, common objects (in the large string to find the number of occurrences of the sequence of ideas)
- A: Drawing Demo
- Requirements: Count the number of occurrences of a large string of small strings
- The large strings and small strings here can be given according to the situation themselves.
17, common objects (in a large string to find the number of occurrences of the Code implementation)
- A: Case Demo
- Count the number of occurrences of a large string of small strings
Java EE Basics (12)