- iOS Programming Cookbook
- Hossam Ghareeb
- 120字
- 2021-07-09 18:29:46
How it works...
The first class we created, StackInt, is a stack that can work only with the Int type. It's good if you are going to use it with Int type only. However, a famous data structure like it can be used with different types, such as String or Double. It's not possible to create different stack class for each type, and here comes the magic of generics; instead we created another class called Stack marked with <T> to say it's going to deal with the generic type T, which can be Int, String, Double, and so on. Then, we create two stack instances, stackOfStrings and stackOfInt, and both share the same code as their class is built with generics.
推薦閱讀
- pcDuino開發(fā)實戰(zhàn)
- Learning OpenDaylight
- Designing Purpose:Built Drones for Ardupilot Pixhawk 2.1
- Linux系統(tǒng)架構(gòu)與運(yùn)維實戰(zhàn)
- Ubuntu Linux操作系統(tǒng)
- 突破平面3ds Max動畫設(shè)計與制作
- 從實踐中學(xué)習(xí)Kali Linux無線網(wǎng)絡(luò)滲透測試
- Fedora 12 Linux應(yīng)用基礎(chǔ)
- iOS 8開發(fā)指南
- Windows 8實戰(zhàn)從入門到精通(超值版)
- μC/OS-III內(nèi)核實現(xiàn)與應(yīng)用開發(fā)實戰(zhàn)指南:基于STM32
- Learning Continuous Integration with Jenkins(Second Edition)
- Linux系統(tǒng)管理初學(xué)者指南:基于CentOS 7.6
- Mastering Sass
- OpenSolaris紅寶書