1. Set Frame (remove repeating string elements in ArrayList)
A: Case Demo
- Requirement: ArrayList removes duplicate values of strings in the collection (the contents of the string are the same)
Idea: Create a new collection method
/** * A: Case Demo * Requirements: ArrayList remove duplicate values of strings in the collection (the contents of the string are the same) * idea: Create a new collection mode */public static void Main (string[] args) {A Rraylist list = new ArrayList (); List.add ("a"); List.add ("a"); List.add ("B"); List.add ("B"); List.add ("B"); List.add ("C"); List.add ("C"); List.add ("C"); List.add ("C"); SYSTEM.OUT.PRINTLN (list); ArrayList newlist = getsingle (list); System.out.println (newlist);} /* * Remove Duplicates * 1, return ArrayList * 2, parameter list ArrayList */public static ArrayList getsingle (ArrayList list) {ArrayList NewList = n EW ArrayList (); Create a new collection Iterator it = List.iterator (); Gets the iterator while (It.hasnext ()) {//Determines whether there is an element in the old collection, String temp = (string) it.next (); Temporarily record each element in the IF (!newlist.contains (temp)) {//If the new collection does not contain the element Newlist.add (temp); Add the element to the new collection}} return newlist; Returns the new collection}
2. Set FRAME (remove duplicate custom object elements in ArrayList)
- A: Case Demo
- Requirement: ArrayList removes duplicate values for custom object elements in the collection (the object has the same member variable value)
- B: Precautions
- Overriding the Equals () method
3. Set FRAME (unique function of LinkedList)
- A:linkedlist class overview
- B:linkedlist Class-specific features
- public void AddFirst (e e) and AddLast (e e)
- Public E GetFirst () and GetLast ()
- Public e Removefirst () and public e removelast ()
- Public E get (int index);
4. Collection framework (Stack and queue data structure)
5, set framework (using LinkedList to simulate the collection of stack data structure and test)
6. Collection Framework (Generic overview and basic usage)
- A: Generic Overview
- B: Generic Benefits
- Increased security (converting run-time errors to compile time)
- Save the trouble of a strong turn
- C: Generic Basic use
- The <> must be a reference data type
- D: Generic Usage considerations
- Pre-and post-generics must be consistent, or the following generics can be omitted without writing (1.7 new feature diamond-shaped generics)
7. Collection Framework (ArrayList store strings and custom objects and traverse the generic version)
- A: Case Demo
- ArrayList storing strings and traversing the generic version
8. Set FRAME (the origin of generics)
- A: Case Demo
- The origin of generics: the introduction of the problem through object transformation
- Early object types can receive arbitrary types of objects, but in actual use there is a problem with type conversions. There is a hidden problem, so Java provides generics to address this security issue.
9, set framework (generic class overview and use)
- A: Generic class overview
- To define a generic type on a class
- B: Define the format
- public class class name < generic type 1,... >
- C: Precautions
- Generic type must be a reference type
- D: Case Demo
10. Collection Framework (Overview and use of generic methods)
- A: Overview of generic methods
- Define generics on a method
- B: Define the format
- Public < generic type > return type method name (generic type variable name)
- C: Case Demo
11. Collection Framework (Overview and use of generic interfaces)
- A: Generic interface Overview
- To define generics on an interface
- B: Define the format
- Public interface interface name < generic type >
- C: Case Demo
- Use of generic interfaces
12. Set FRAME (generic high-level wildcard character)
- A: Generic wildcard characters <?>
- Any type, if not explicitly, is object and any Java class.
- B:? Extends E
- Down qualification, E and its subclasses
- C:? Super E
- Limit up, E and its parent class
13. Collection Framework (Enhanced for overview and use)
14. Collection Framework (ArrayList store strings and custom objects and traverse enhanced for version)
15, set frame (three kinds of iterations can be deleted)
- Normal for loop, can be deleted, but index to--
- Iterators, which can be deleted, but must use the Remove method of the iterator itself, or a concurrency modification exception will occur
- Enhanced for loop cannot be deleted
16. Collection Framework (overview and use of static import)
- A: Static Import Overview
- B: Format:
- Import static package name .... class name. method name;
- Levels that can be imported directly to a method
- C: Precautions
- The method must be static, and if there are multiple static methods with the same name, it is easy to know who to use. This time, you must prefix it. This shows that the meaning is not big, so generally not, but to be able to read.
17. Set Frame (overview and use of variable parameters)
- A: Overview of variable parameters
- When defining a method, you do not know how many parameters to define
- B: Format
- Modifier returns a value type method name (data type ... Variable name) {}
- C: Precautions:
- The variable here is actually an array
- If a method has a variable parameter, and there are multiple parameters, then the variable parameter is definitely the last
18. Collection Framework (use of the Aslist () method of the Arrays tool class)
- A: Case Demo
- Use of the Aslist () method of the Arrays tool class
- Collection ToArray (t[] a) generic version of the set-to-go array
19, set FRAME (set nested arraylist nested ArrayList)
- A: Case Demo
- Nesting nested arraylist arraylist nested sets
Java EE Fundamentals (16)/collections