📜  框架中的多态性 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:48.438000             🧑  作者: Mango

代码示例2
Set set = new HashSet<>();
List list = new ArrayList<>();
set.add(4);  ==> HashSet overrides add() method from Collection Interface
list.add(8); ==> ArrayList overrides add() method from Collection Interface

WebDriver driver1 = new ChromeDriver();
driver1.get("xxxxxx"); ChromeDriver overrides get/findElement/etc.
                                      methods from WebDriver Interface.

WebDriver driver2 = new FirefoxDriver();
driver2.get("xxxxxx"); FirefoxDriver overrides 
get/findElement/etc. methods from WebDriver Interface.