《Thinking in Java》第二版: Bruce Eckel的经典之作

4星 · 超过85%的资源 需积分: 29 4 下载量 56 浏览量 更新于2024-09-28 收藏 4.63MB PDF 举报
"《Thinking in Java》第二版是Bruce Eckel创作的一本Java编程经典书籍,由侯捷和王建興翻译。这本书获得了读者的高度评价,被认为是Java书籍中的卓越典范,适合初学者和有经验的程序员。书中通过丰富的例子和深入的解释,帮助读者理解和掌握Java语言的核心概念和高级特性。" 在《Thinking in Java》第二版中,作者Bruce Eckel不仅介绍了Java的基础语法,如数据类型、控制结构、类和对象,还深入探讨了面向对象编程的原理和实践。他强调了设计模式、异常处理、多线程、输入/输出(I/O)、网络编程以及集合框架等关键主题。这本书的独特之处在于其系统性和连贯性,使得读者可以从整体上理解Java的生态系统。 书中详细讲解了类的设计,包括封装、继承和多态等面向对象的基本概念。此外,还深入讨论了接口(interface)和抽象类(abstract class)的区别,以及何时选择使用它们。关于异常处理,书中阐述了如何有效地捕获和处理错误,以提高代码的健壮性。 在集合框架部分,作者介绍了ArrayList、LinkedList、HashSet、HashMap等数据结构,并对比了数组(array)和Vector的性能差异及其适用场景。这些内容对于理解和优化Java程序的内存管理和效率至关重要。 对于Java的I/O系统,书中涵盖了流(streams)的概念,包括字符流和字节流,以及如何进行文件操作和网络通信。这部分知识对于开发涉及文件读写或网络应用的Java程序非常重要。 此外,书中的例子都是经过精心挑选的,旨在让读者在实践中学习。通过实际编写和运行代码,读者能够更好地掌握理论知识,并提升解决问题的能力。《Thinking in Java》第二版也涵盖了单元测试,鼓励程序员养成良好的测试习惯,确保代码的质量和可靠性。 《Thinking in Java》是一本全面而深入的Java教程,适合所有级别的Java开发者,无论你是刚刚接触Java的新手,还是希望深化对Java理解的资深开发者,都能从中受益匪浅。这本书的广泛赞誉和高评价证明了其在Java教育领域的权威地位。

Write java code: Copy the files, small_weapons.txt, and large_weapons.txt from the assignment folder on Blackboard and save them to your folder. For testing purposes, you should use the small file. Use the large file when you think the application works correctly. To see what is in the files use a text editor. Nilesh is currently enjoying the action RPG game Torchlight 2 which is an awesome game and totally blows Auction House Simulator 3, oh sorry, that should be Diablo 3, out of the water. He has got a file containing info on some of the unique weapons in the game. The transaction file contains the following information: Weapon Name (string) Weapon Type (string) Damage (int) Weapon Speed (double) … To tell if one weapon is better than another you need to know the Damage Per Second (DPS) the weapon does, since weapons have a different attack speed. DPS is calculated by taking the damage value and dividing it by the attack speed.a) You will write a program that will allow Nilesh to load the file and display the weapon info and DPS of every weapon in the input file. When the user chooses to open a weapon file, they are required to type in the filename. It will then read the 4 values about a particular weapon and then display the 4 values to the console window on one line neatly padded along with the DPS of the weapon. This is repeated until the end of the file. b) Modify your code from a) so that the weapon information written to the console window is also written to a text file. The user should be able to specify the name of the file. Add a header to the beginning of the file which has column headers for each column. At the end of the text file display the total number of weapons in the file. c) Document your code appropriately and add your name and id number as comments at the top of your code. Please also submit this text file you have created. Enter the file you want to search end with .txt: large_weapons.txt 1 Blackfang Bludgeon Great Hammer 489 1.44 339.58333333333337 2 Bones 2 Boneshredder Great Axe 256 0.84 304.76190476190476 3 Comet's Tail Great Sword 872 1.2 726.6666666666667 4 Decapitator Great Sword 188 1.08 174.07407407407408 5 Demolisher Great Hammer 887 1.32 671.9696969696969

2023-05-27 上传