《java语言程序设计 38章》(英文原版)
java四大名著
1. 《Java编程思想(第4版)》基本信息原书名:Thinking in Java (4th Edition)原出版社:Prentice Hall PTR作者:(美)Bruce Eckel [作译者介绍]译者:陈昊鹏丛书名:计算机科学丛书出版社:机械工业出版社ISBN:9787111213826上架时间:2007-6-19出版日期:2007年6月推荐语本书是全球程序员必备图书《Java编程思想》的最新版本(《Java编程思想(英文影印版.第4版)》)本书曾获:·被china-pub会员评为“2007年我最喜爱的十大技术图书”之一·2003年《Software Development》杂志最佳书籍Jolt大奖·2003年《Java Developer’s Journal》读者选择最佳书籍奖·2001年《Java World》编辑选择最佳书籍奖·2000年《Java World》读者选择最佳书籍奖·1999年《Software Development》杂志最佳产品奖·1998年《Java Developer’s Journal》编辑选择最佳书籍奖内容简介本书赢得了全球程序员的广泛赞誉,即使是最晦涩的概念,在bruce eckel的文字亲和力和小而直接的编程示例面前也会化解于无形。
从java的基础语法到最高级特性(深入的面向对象概念、多线程、自动项目构建、单元测试和调试等),本书都能逐步指导你轻松掌握。
从本书获得的各项大奖以及来自世界各地的读者评论中,不难看出这是一本经典之作。
本书的作者拥有多年教学经验,对c、c++以及java语言都有独到、深入的见解,以通俗易懂及小而直接的示例解释了一个个晦涩抽象的概念。
本书共22章,包括操作符、控制执行流程、访问权限控制、复用类、多态、接口、通过异常处理错误、字符串、泛型、数组、容器深入研究、java i/o系统、枚举类型、并发以及图形化用户界面等内容。
计算机java外文翻译外文文献英文文献
英文原文:Title: Business Applications of Java. Author: Erbschloe, Michael, Business Applications of Java -- Research Starters Business, 2008DataBase: Research Starters - BusinessBusiness Applications of JavaThis article examines the growing use of Java technology in business applications. The history of Java is briefly reviewed along with the impact of open standards on the growth of the World Wide Web. Key components and concepts of the Java programming language are explained including the Java Virtual Machine. Examples of how Java is being used bye-commerce leaders is provided along with an explanation of how Java is used to develop data warehousing, data mining, and industrial automation applications. The concept of metadata modeling and the use of Extendable Markup Language (XML) are also explained.Keywords Application Programming Interfaces (API's); Enterprise JavaBeans (EJB); Extendable Markup Language (XML); HyperText Markup Language (HTML); HyperText Transfer Protocol (HTTP); Java Authentication and Authorization Service (JAAS); Java Cryptography Architecture (JCA); Java Cryptography Extension (JCE); Java Programming Language; Java Virtual Machine (JVM); Java2 Platform, Enterprise Edition (J2EE); Metadata Business Information Systems > Business Applications of JavaOverviewOpen standards have driven the e-business revolution. Networking protocol standards, such as Transmission Control Protocol/Internet Protocol (TCP/IP), HyperText Transfer Protocol (HTTP), and the HyperText Markup Language (HTML) Web standards have enabled universal communication via the Internet and the World Wide Web. As e-business continues to develop, various computing technologies help to drive its evolution.The Java programming language and platform have emerged as major technologies for performing e-business functions. Java programming standards have enabled portability of applications and the reuse of application components across computing platforms. Sun Microsystems' Java Community Process continues to be a strong base for the growth of the Java infrastructure and language standards. This growth of open standards creates new opportunities for designers and developers of applications and services (Smith, 2001).Creation of Java TechnologyJava technology was created as a computer programming tool in a small, secret effort called "the Green Project" at Sun Microsystems in 1991. The Green Team, fully staffed at 13 people and led by James Gosling, locked themselves away in an anonymous office on Sand Hill Road in Menlo Park, cut off from all regular communications with Sun, and worked around the clock for18 months. Their initial conclusion was that at least one significant trend would be the convergence of digitally controlled consumer devices and computers. A device-independent programming language code-named "Oak" was the result.To demonstrate how this new language could power the future of digital devices, the Green Team developed an interactive, handheld home-entertainment device controller targeted at the digital cable television industry. But the idea was too far ahead of its time, and the digital cable television industry wasn't ready for the leap forward that Java technology offered them. As it turns out, the Internet was ready for Java technology, and just in time for its initial public introduction in 1995, the team was able to announce that the Netscape Navigator Internet browser would incorporate Java technology ("Learn about Java," 2007).Applications of JavaJava uses many familiar programming concepts and constructs and allows portability by providing a common interface through an external Java Virtual Machine (JVM). A virtual machine is a self-contained operating environment, created by a software layer that behaves as if it were a separate computer. Benefits of creating virtual machines include better exploitation of powerful computing resources and isolation of applications to prevent cross-corruption and improve security (Matlis, 2006).The JVM allows computing devices with limited processors or memory to handle more advanced applications by calling up software instructions inside the JVM to perform most of the work. This also reduces the size and complexity of Java applications because many of the core functions and processing instructions were built into the JVM. As a result, software developersno longer need to re-create the same application for every operating system. Java also provides security by instructing the application to interact with the virtual machine, which served as a barrier between applications and the core system, effectively protecting systems from malicious code.Among other things, Java is tailor-made for the growing Internet because it makes it easy to develop new, dynamic applications that could make the most of the Internet's power and capabilities. Java is now an open standard, meaning that no single entity controls its development and the tools for writing programs in the language are available to everyone. The power of open standards like Java is the ability to break down barriers and speed up progress.Today, you can find Java technology in networks and devices that range from the Internet and scientific supercomputers to laptops and cell phones, from Wall Street market simulators to home game players and credit cards. There are over 3 million Java developers and now there are several versions of the code. Most large corporations have in-house Java developers. In addition, the majority of key software vendors use Java in their commercial applications (Lazaridis, 2003).ApplicationsJava on the World Wide WebJava has found a place on some of the most popular websites in the world and the uses of Java continues to grow. Java applications not only provide unique user interfaces, they also help to power the backend of websites. Two e-commerce giants that everybody is probably familiar with (eBay and Amazon) have been Java pioneers on the World Wide Web.eBayFounded in 1995, eBay enables e-commerce on a local, national and international basis with an array of Web sites-including the eBay marketplaces, PayPal, Skype, and -that bring together millions of buyers and sellers every day. You can find it on eBay, even if you didn't know it existed. On a typical day, more than 100 million items are listed on eBay in tens of thousands of categories. Recent listings have included a tunnel boring machine from the Chunnel project, a cup of water that once belonged to Elvis, and the Volkswagen that Pope Benedict XVI owned before he moved up to the Popemobile. More than one hundred million items are available at any given time, from the massive to the miniature, the magical to the mundane, on eBay; the world's largest online marketplace.eBay uses Java almost everywhere. To address some security issues, eBay chose Sun Microsystems' Java System Identity Manager as the platform for revamping its identity management system. The task at hand was to provide identity management for more than 12,000 eBay employees and contractors.Now more than a thousand eBay software developers work daily with Java applications. Java's inherent portability allows eBay to move to new hardware to take advantage of new technology, packaging, or pricing, without having to rewrite Java code ("eBay drives explosive growth," 2007).Amazon (a large seller of books, CDs, and other products) has created a Web Service application that enables users to browse their product catalog and place orders. uses a Java application that searches the Amazon catalog for books whose subject matches a user-selected topic. The application displays ten books that match the chosen topic, and shows the author name, book title, list price, Amazon discount price, and the cover icon. The user may optionally view one review per displayed title and make a buying decision (Stearns & Garishakurthi, 2003).Java in Data Warehousing & MiningAlthough many companies currently benefit from data warehousing to support corporate decision making, new business intelligence approaches continue to emerge that can be powered by Java technology. Applications such as data warehousing, data mining, Enterprise Information Portals (EIP's), and Knowledge Management Systems (which can all comprise a businessintelligence application) are able to provide insight into customer retention, purchasing patterns, and even future buying behavior.These applications can not only tell what has happened but why and what may happen given certain business conditions; allowing for "what if" scenarios to be explored. As a result of this information growth, people at all levels inside the enterprise, as well as suppliers, customers, and others in the value chain, are clamoring for subsets of the vast stores of information such as billing, shipping, and inventory information, to help them make business decisions. While collecting and storing vast amounts of data is one thing, utilizing and deploying that data throughout the organization is another.The technical challenges inherent in integrating disparate data formats, platforms, and applications are significant. However, emerging standards such as the Application Programming Interfaces (API's) that comprise the Java platform, as well as Extendable Markup Language (XML) technologies can facilitate the interchange of data and the development of next generation data warehousing and business intelligence applications. While Java technology has been used extensively for client side access and to presentation layer challenges, it is rapidly emerging as a significant tool for developing scaleable server side programs. The Java2 Platform, Enterprise Edition (J2EE) provides the object, transaction, and security support for building such systems.Metadata IssuesOne of the key issues that business intelligence developers must solve is that of incompatible metadata formats. Metadata can be defined as information about data or simply "data about data." In practice, metadata is what most tools, databases, applications, and other information processes use to define, relate, and manipulate data objects within their own environments. It defines the structure and meaning of data objects managed by an application so that the application knows how to process requests or jobs involving those data objects. Developers can use this schema to create views for users. Also, users can browse the schema to better understand the structure and function of the database tables before launching a query.To address the metadata issue, a group of companies (including Unisys, Oracle, IBM, SAS Institute, Hyperion, Inline Software and Sun) have joined to develop the Java Metadata Interface (JMI) API. The JMI API permits the access and manipulation of metadata in Java with standard metadata services. JMI is based on the Meta Object Facility (MOF) specification from the Object Management Group (OMG). The MOF provides a model and a set of interfaces for the creation, storage, access, and interchange of metadata and metamodels (higher-level abstractions of metadata). Metamodel and metadata interchange is done via XML and uses the XML Metadata Interchange (XMI) specification, also from the OMG. JMI leverages Java technology to create an end-to-end data warehousing and business intelligence solutions framework.Enterprise JavaBeansA key tool provided by J2EE is Enterprise JavaBeans (EJB), an architecture for the development of component-based distributed business applications. Applications written using the EJB architecture are scalable, transactional, secure, and multi-user aware. These applications may be written once and then deployed on any server platform that supports J2EE. The EJB architecture makes it easy for developers to write components, since they do not need to understand or deal with complex, system-level details such as thread management, resource pooling, and transaction and security management. This allows for role-based development where component assemblers, platform providers and application assemblers can focus on their area of responsibility further simplifying application development.EJB's in the Travel IndustryA case study from the travel industry helps to illustrate how such applications could function. A travel company amasses a great deal of information about its operations in various applications distributed throughout multiple departments. Flight, hotel, and automobile reservation information is located in a database being accessed by travel agents worldwide. Another application contains information that must be updated with credit and billing historyfrom a financial services company. Data is periodically extracted from the travel reservation system databases to spreadsheets for use in future sales and marketing analysis.Utilizing J2EE, the company could consolidate application development within an EJB container, which can run on a variety of hardware and software platforms allowing existing databases and applications to coexist with newly developed ones. EJBs can be developed to model various data sets important to the travel reservation business including information about customer, hotel, car rental agency, and other attributes.Data Storage & AccessData stored in existing applications can be accessed with specialized connectors. Integration and interoperability of these data sources is further enabled by the metadata repository that contains metamodels of the data contained in the sources, which then can be accessed and interchanged uniformly via the JMI API. These metamodels capture the essential structure and semantics of business components, allowing them to be accessed and queried via the JMI API or to be interchanged via XML. Through all of these processes, the J2EE infrastructure ensures the security and integrity of the data through transaction management and propagation and the underlying security architecture.To consolidate historical information for analysis of sales and marketing trends, a data warehouse is often the best solution. In this example, data can be extracted from the operational systems with a variety of Extract, Transform and Load tools (ETL). The metamodels allow EJBsdesigned for filtering, transformation, and consolidation of data to operate uniformly on datafrom diverse data sources as the bean is able to query the metamodel to identify and extract the pertinent fields. Queries and reports can be run against the data warehouse that contains information from numerous sources in a consistent, enterprise-wide fashion through the use of the JMI API (Mosher & Oh, 2007).Java in Industrial SettingsMany people know Java only as a tool on the World Wide Web that enables sites to perform some of their fancier functions such as interactivity and animation. However, the actual uses for Java are much more widespread. Since Java is an object-oriented language like C++, the time needed for application development is minimal. Java also encourages good software engineering practices with clear separation of interfaces and implementations as well as easy exception handling.In addition, Java's automatic memory management and lack of pointers remove some leading causes of programming errors. Most importantly, application developers do not need to create different versions of the software for different platforms. The advantages available through Java have even found their way into hardware. The emerging new Java devices are streamlined systems that exploit network servers for much of their processing power, storage, content, and administration.Benefits of JavaThe benefits of Java translate across many industries, and some are specific to the control and automation environment. For example, many plant-floor applications use relatively simple equipment; upgrading to PCs would be expensive and undesirable. Java's ability to run on any platform enables the organization to make use of the existing equipment while enhancing the application.IntegrationWith few exceptions, applications running on the factory floor were never intended to exchange information with systems in the executive office, but managers have recently discovered the need for that type of information. Before Java, that often meant bringing together data from systems written on different platforms in different languages at different times. Integration was usually done on a piecemeal basis, resulting in a system that, once it worked, was unique to the two applications it was tying together. Additional integration required developing a brand new system from scratch, raising the cost of integration.Java makes system integration relatively easy. Foxboro Controls Inc., for example, used Java to make its dynamic-performance-monitor software package Internet-ready. This software provides senior executives with strategic information about a plant's operation. The dynamic performance monitor takes data from instruments throughout the plant and performs variousmathematical and statistical calculations on them, resulting in information (usually financial) that a manager can more readily absorb and use.ScalabilityAnother benefit of Java in the industrial environment is its scalability. In a plant, embedded applications such as automated data collection and machine diagnostics provide critical data regarding production-line readiness or operation efficiency. These data form a critical ingredient for applications that examine the health of a production line or run. Users of these devices can take advantage of the benefits of Java without changing or upgrading hardware. For example, operations and maintenance personnel could carry a handheld, wireless, embedded-Java device anywhere in the plant to monitor production status or problems.Even when internal compatibility is not an issue, companies often face difficulties when suppliers with whom they share information have incompatible systems. This becomes more of a problem as supply-chain management takes on a more critical role which requires manufacturers to interact more with offshore suppliers and clients. The greatest efficiency comes when all systems can communicate with each other and share information seamlessly. Since Java is so ubiquitous, it often solves these problems (Paula, 1997).Dynamic Web Page DevelopmentJava has been used by both large and small organizations for a wide variety of applications beyond consumer oriented websites. Sandia, a multiprogram laboratory of the U.S. Department of Energy's National Nuclear Security Administration, has developed a unique Java application. The lab was tasked with developing an enterprise-wide inventory tracking and equipment maintenance system that provides dynamic Web pages. The developers selected Java Studio Enterprise 7 for the project because of its Application Framework technology and Web Graphical User Interface (GUI) components, which allow the system to be indexed by an expandable catalog. The flexibility, scalability, and portability of Java helped to reduce development timeand costs (Garcia, 2004)IssueJava Security for E-Business ApplicationsTo support the expansion of their computing boundaries, businesses have deployed Web application servers (WAS). A WAS differs from a traditional Web server because it provides a more flexible foundation for dynamic transactions and objects, partly through the exploitation of Java technology. Traditional Web servers remain constrained to servicing standard HTTP requests, returning the contents of static HTML pages and images or the output from executed Common Gateway Interface (CGI ) scripts.An administrator can configure a WAS with policies based on security specifications for Java servlets and manage authentication and authorization with Java Authentication andAuthorization Service (JAAS) modules. An authentication and authorization service can bewritten in Java code or interface to an existing authentication or authorization infrastructure. Fora cryptography-based security infrastructure, the security server may exploit the Java Cryptography Architecture (JCA) and Java Cryptography Extension (JCE). To present the user with a usable interaction with the WAS environment, the Web server can readily employ a formof "single sign-on" to avoid redundant authentication requests. A single sign-on preserves user authentication across multiple HTTP requests so that the user is not prompted many times for authentication data (i.e., user ID and password).Based on the security policies, JAAS can be employed to handle the authentication process with the identity of the Java client. After successful authentication, the WAS securitycollaborator consults with the security server. The WAS environment authentication requirements can be fairly complex. In a given deployment environment, all applications or solutions may not originate from the same vendor. In addition, these applications may be running on different operating systems. Although Java is often the language of choice for portability between platforms, it needs to marry its security features with those of the containing environment.Authentication & AuthorizationAuthentication and authorization are key elements in any secure information handling system. Since the inception of Java technology, much of the authentication and authorization issues have been with respect to downloadable code running in Web browsers. In many ways, this had been the correct set of issues to address, since the client's system needs to be protected from mobile code obtained from arbitrary sites on the Internet. As Java technology moved from a client-centric Web technology to a server-side scripting and integration technology, it required additional authentication and authorization technologies.The kind of proof required for authentication may depend on the security requirements of a particular computing resource or specific enterprise security policies. To provide such flexibility, the JAAS authentication framework is based on the concept of configurable authenticators. This architecture allows system administrators to configure, or plug in, the appropriate authenticatorsto meet the security requirements of the deployed application. The JAAS architecture also allows applications to remain independent from underlying authentication mechanisms. So, as new authenticators become available or as current authentication services are updated, system administrators can easily replace authenticators without having to modify or recompile existing applications.At the end of a successful authentication, a request is associated with a user in the WAS user registry. After a successful authentication, the WAS consults security policies to determine if the user has the required permissions to complete the requested action on the servlet. This policy canbe enforced using the WAS configuration (declarative security) or by the servlet itself (programmatic security), or a combination of both.The WAS environment pulls together many different technologies to service the enterprise. Because of the heterogeneous nature of the client and server entities, Java technology is a good choice for both administrators and developers. However, to service the diverse security needs of these entities and their tasks, many Java security technologies must be used, not only at a primary level between client and server entities, but also at a secondary level, from served objects. By using a synergistic mix of the various Java security technologies, administrators and developers can make not only their Web application servers secure, but their WAS environments secure as well (Koved, 2001).ConclusionOpen standards have driven the e-business revolution. As e-business continues to develop, various computing technologies help to drive its evolution. The Java programming language and platform have emerged as major technologies for performing e-business functions. Java programming standards have enabled portability of applications and the reuse of application components. Java uses many familiar concepts and constructs and allows portability by providing a common interface through an external Java Virtual Machine (JVM). Today, you can find Java technology in networks and devices that range from the Internet and scientific supercomputers to laptops and cell phones, from Wall Street market simulators to home game players and credit cards.Java has found a place on some of the most popular websites in the world. Java applications not only provide unique user interfaces, they also help to power the backend of websites. While Java technology has been used extensively for client side access and in the presentation layer, it is also emerging as a significant tool for developing scaleable server side programs.Since Java is an object-oriented language like C++, the time needed for application development is minimal. Java also encourages good software engineering practices with clear separation of interfaces and implementations as well as easy exception handling. Java's automatic memory management and lack of pointers remove some leading causes of programming errors. The advantages available through Java have also found their way into hardware. The emerging new Java devices are streamlined systems that exploit network servers for much of their processing power, storage, content, and administration.中文翻译:标题:Java的商业应用。
国外用来学javaweb的书
国外用来学javaweb的书JavaWeb是一种基于Java语言的Web开发技术,它在国内外都有广泛的应用和研究。
对于想要学习JavaWeb的开发者来说,选择一本好的教材是非常重要的。
在国外,有许多优秀的书籍可以帮助开发者系统地学习JavaWeb技术。
下面我将介绍几本在国外广受好评的用来学习JavaWeb的书籍。
1.《Head First Servlets and JSP》这本书是由Kathy Sierra和Bert Bates合著的,是一本非常受欢迎的JavaWeb入门教材。
它以轻松幽默的方式讲解Servlet和JSP的基本概念和用法,适合初学者阅读。
书中通过大量的实例和练习,帮助读者理解和掌握JavaWeb开发的核心知识。
2.《JavaServer Faces in Action》这本书由Kito D. Mann和Ryan Lubke合著,是一本关于JavaServer Faces(JSF)技术的权威指南。
JSF是一种用于构建用户界面的JavaWeb框架,它提供了丰富的组件库和强大的事件处理机制。
这本书详细介绍了JSF的各个方面,包括表单处理、数据绑定、验证和国际化等内容,适合有一定Java基础的读者学习。
3.《Spring in Action》这本书由Craig Walls合著,是一本关于Spring框架的经典教材。
Spring是一个轻量级的Java开发框架,它提供了丰富的功能和灵活的配置方式,被广泛应用于JavaWeb开发中。
这本书详细介绍了Spring框架的各个模块,包括依赖注入、AOP、MVC等,同时也讲解了如何使用Spring进行数据库访问、事务管理和测试等。
对于想要学习Spring框架的开发者来说,这本书是一本不可或缺的参考资料。
4.《Java Persistence with Hibernate》这本书由Christian Bauer和Gavin King合著,是一本关于Hibernate 持久化框架的权威指南。
Java语言程序设计基础篇英文版第十版课程设计
Java Programming Fundamentals, 10th Edition CourseDesign (English Version)IntroductionJava Programming Fundamentals is a comprehensive course that covers the basic concepts and principles of Java programming. In this course, students will learn to design, code, and test Java programs while developing a strong foundation in programming logic and object-oriented programming concepts. This course is designed for students who are new to programming and want to learn Java programming from scratch.Course ObjectivesThe mn objective of this course is to provide students with a solid foundation in programming using the Java language. Upon completion of this course, students will be able to:•Understand the basic syntax and structure of the Java programming language•Design, code, and test simple Java programs•Use decision structures and loops in Java programming•Work with arrays and arraylists•Understand object-oriented programming concepts•Implement inheritance and polymorphism in Java programming•Understand Java class libraries and use them in Java programming•Develop event-driven programs using graphical user interfacesCourse OutlineThe course is divided into several chapters, each covering adifferent aspect of Java programming fundamentals. The following is a detled outline of the course:Chapter 1: Getting Started with Java•Introduction to Java programming language•Understanding the basic structure of a Java program•Writing and running a Java program•Understanding variables, data types, and constants•Basic Input/Output operationsChapter 2: Control Structures•Understanding decision structures•Using if statement, if-else statement, and nested if statements•Understanding loops and using while, do-while, and for loops•Understanding break and continue statements•Using switch statementChapter 3: Arrays and Arraylists•Understanding arrays•Declaring and initializing arrays•Multidimensional arrays•Understanding arraylist•Using arraylist class methodsChapter 4: Object-Oriented Programming Concepts•Introduction to object-oriented programming•Understanding classes and objects•Encapsulation: Access modifiers, getters, and setters•Constructors and overloading•Methods and method overloadingChapter 5: Inheritance and Polymorphism•Understanding inheritance•Using superclass and subclass•Polymorphism: Method overloading and overriding•Casting objects•Abstract classes and interfacesChapter 6: Java Class Libraries•Understanding Java class libraries•Using the String class•Using the Math class•Using the Date class•Using the File classChapter 7: Graphical User Interfaces•Understanding event-driven programming•Using the Swing library•Designing a user interface using JFrame, JDialog, and JPanel •Using event listeners•Designing a GUI-based applicationCourse Requirements•Basic computer skills•Basic understanding of programming concepts is helpful but not required•Java Development Kit (JDK) version 8 or later•Integrated Development Environment (IDE) such as Eclipse or NetBeansGrading PolicyThe final grade for this course will be calculated based on the following components:•Assignments (50%)•Midterm Exam (20%)•Final Exam (30%)ConclusionJava Programming Fundamentals, 10th Edition course is designed to provide students with a solid foundation in Java programming language and object-oriented programming concepts. By the end of this course, students will be able to write simple Java programs, use decision constructs and loops, work with arrays and arraylists, implement inheritance and polymorphism, understand Java class libraries, and develop graphical user interfaces. This course is intended for anyone who is interested in learning Java programming from scratch.。
全国计算机等级考试《二级java语言程序设计》专用教材【考纲分析+考点精讲+真题演练+强化习题】500()
全国计算机等级考试《二级Java语言程序设计》专用教材【考纲分析+考点精讲+真题演练+强化习题】最新资料,WORD格式,可编辑修改!目录第一部分公共基础知识........................................................第1章数据结构与算法....................................................考纲分析..............................................................考点精讲..............................................................1.1 算法.......................................................1.2 数据结构的基本概念...........................................1.3 线性表及其顺序存储结构.......................................1.4 栈和队列.....................................................1.5 线性链表.....................................................1.6 树与二叉树...................................................1.7 查找技术.....................................................1.8 排序技术.....................................................强化习题..............................................................第2章程序设计基础......................................................考纲分析..............................................................考点精讲..............................................................2.1 程序设计方法与风格...........................................2.2 结构化程序设计...............................................2.3 面向对象的程序设计...........................................强化习题..............................................................第3章软件工程基础......................................................考纲分析..............................................................考点精讲..............................................................3.1 软件工程基本概念.............................................3.2 结构化分析方法...............................................3.3 结构化设计方法...............................................3.4 软件测试.....................................................3.5 程序的调试...................................................强化习题..............................................................第4章数据库设计基础....................................................考纲分析..............................................................考点精讲..............................................................4.1 数据库系统的基本概念.........................................4.2 数据模型.....................................................4.3 关系代数.....................................................4.4 数据库设计与管理.............................................强化习题.............................................................. 第二部分Java语言程序设计....................................................第1章Java语言概论......................................................考纲分析..............................................................考点精讲..............................................................1.1 Java语言简介.................................................1.2 Java语言面向对象编程.........................................强化习题..............................................................第2章基本数据类型......................................................考纲分析..............................................................考点精讲..............................................................2.1 概述.......................................................2.2 基本数据类型.................................................2.3 引用数据类型.................................................2.4 Java类库中对基本数据类型的对象包装器(wrapper)类 ...........强化习题..............................................................第3章运算符和表达式....................................................考纲分析..............................................................考点精讲..............................................................3.1 概述.......................................................3.2 算术运算符和算术表达式.......................................3.3 关系运算符和关系表达式.......................................3.4 布尔逻辑运算符和布尔逻辑表达式...............................3.5 位运算符和位运算表达式.......................................3.6 赋值运算符和赋值表达式.......................................3.7 条件运算符与条件表达式.......................................3.8 运算符的优先级和复杂表达式...................................3.9 表达式语句...................................................强化习题..............................................................第4章流程控制..........................................................考纲分析..............................................................考点精讲..............................................................4.1 概述.......................................................4.2 分支(选择)语句.............................................4.4 跳转语句.....................................................4.5 循环语句与分支语句的嵌套.....................................4.6 递归.......................................................强化习题.............................................................. 第5章Java的继承、多态、高级类特性和数组 ...............................考纲分析..............................................................考点精讲..............................................................5.1 概述.......................................................5.2 覆盖方法.....................................................5.3 重载方法.....................................................5.4 高级类特性...................................................5.5 内部类.......................................................5.6 数组.......................................................强化习题.............................................................. 第6章异常和断言........................................................考纲分析..............................................................考点精讲..............................................................6.1 概述.......................................................6.2 异常处理类型.................................................6.3 异常处理编程的提醒...........................................6.4 断言.......................................................强化习题.............................................................. 第7章输入输出及文件操作................................................考纲分析..............................................................考点精讲..............................................................7.1 概述.......................................................7.2 文件.......................................................7.3 字节流.......................................................7.4 字符流.......................................................7.5 对象流.......................................................7.6 过滤流.......................................................7.7 管道流.......................................................7.8 不同流的速度比较.............................................7.9 输入输出流和正则表达式.......................................7.10 Java I/O流的其他应用........................................强化习题.............................................................. 第8章线程............................................................考纲分析..............................................................考点精讲..............................................................8.1 概述.......................................................8.3 线程的调度与控制.............................................8.4 线程同步.....................................................8.5 线程状态与生命周期...........................................8.6 线程相关的其他类与方法.......................................强化习题.............................................................. 第9章编写图形用户界面..................................................考纲分析..............................................................考点精讲..............................................................9.1 概述.......................................................9.2 用AWT编写图形用户界面.......................................9.3 AWT事件处理模型..............................................9.4 AWT组件库....................................................9.5 用Swing编写图形用户界面.....................................9.6 Swing组件和容器..............................................9.7 Swing的事件处理机制..........................................强化习题.............................................................. 第10章Applet程序设计...................................................考纲分析..............................................................考点精讲..............................................................10.1 Applet的基本概念............................................10.2 Applet的编写................................................10.3 Applet中的图形化用户界面GUI................................10.4 Applet的多媒体支持..........................................10.5 Applet与工作环境的通信......................................强化习题.............................................................. 第11章集合与泛型.......................................................考纲分析..............................................................考点精讲..............................................................11.1 概述......................................................11.2 集合框架....................................................11.3 简单集合类..................................................11.4 泛型......................................................强化习题.............................................................. 第12章Java SDK 6.0的下载和操作.........................................考纲分析..............................................................考点精讲..............................................................12.1 Java SDK 6.0的下载与安装....................................12.2 Java SDK 6.0的操作命令......................................12.3 Java编程规范................................................强化习题..............................................................第一部分公共基础知识第1章数据结构与算法考纲分析1.算法的基本概念,算法复杂度的概念和意义(时间复杂度与空间复杂度)。
java程序设计(辛运帏饶一梅马素霞第二版)课后习题答案
以下是《Java程序设计》(第二版)的全部课后答案,不包括简答题,概念题,只是程序设计题目。
//习题2.2import java.util.*;class MyDate{private int year;private int month;private int day;public MyDate(int y,int m,int d){//构造函数,构造方法year=y;month=m;day=d;}//end public MyDate(int y,int m,int d)public int getYear(){//返回年return year;}//end getYear()public int getMonth(){//返回月return month;}//end getMonth()public int getDay(){//返回日return day;}//end getDay()}//end class MyDateclass Employee{private String name;private double salary;private MyDate hireDay;public Employee(String n,double s,MyDate d){name=n;salary=s;hireDay=d;}//end public Employee(String n,double s,MyDate d)public void print(){System.out.println("名字:"+name+"\n工资:"+salary+"\n雇佣年份:"+hireYear()+"\n");}//end print()public void raiseSalary(double byPercent){salary*=1+byPercent/100;}//endpublic int hireYear(){return hireDay.getYear();}}//end class Employeepublic class MyTestClass {public static void main(String[] args) {Employee[]staff=new Employee[3];staff[0]=new Employee("Harry Hacker",35000,new MyDate(1989,10,1));staff[1]=new Employee("Carl Carcker",75000,new MyDate(1987,12,15));staff[2]=new Employee("Tony Tester",38000,new MyDate(1990,3,12));int integerValue;System.out.println("The information of employee are:");for(integerValue=0;integerValue<=2;integerValue++){staff[integerValue].raiseSalary(5);}//end for()for(integerValue=0;integerValue<=2;integerValue++){staff[integerValue].print();}//end for()}//end main()}//end class MyTestClass//习题2.4import java.util.*;public class DataType {public static void main(String[] args) {boolean flag;char yesChar;byte finByte;int intValue;long longValue;short shortValue;float floatValue;double doubleValue;flag=true;yesChar='y';finByte=30;intValue=-7000;longValue=200l;shortValue=20000;floatValue=9.997E-5f;doubleValue=floatV alue*floatValue;System.out.println("the values are:");System.out.println("布尔类型变量flag="+flag);System.out.println("字符型变量yesChar="+yesChar);System.out.println("字节型变量finByte="+finByte);System.out.println("整型变量intValue="+intValue);System.out.println("长整型变量longValue="+longValue);System.out.println("短整型变量shortValue="+shortValue);System.out.println("浮点型变量floatValue="+floatValue);System.out.println("双精度浮点型变量doubleValue="+doubleValue); }//end main()}//习题2.9import java.util.*;class PubTest1{private int ivar1;private float fvar1,fvar2;public PubTest1(){fvar2=0.0f;}public float sum_f_I(){fvar2=fvar1+ivar1;return fvar2;}public void print(){System.out.println("fvar2="+fvar2);}public void setIvar1(int ivalue){ivar1=ivalue;}public void setFvar1(float ivalue){fvar1=ivalue;}}public class PubMainTest {public static void main(String[] args) {PubTest1 pubt1=new PubTest1();pubt1.setIvar1(10);pubt1.setFvar1(100.02f);pubt1.sum_f_I();pubt1.print();}}//习题2.10import java.util.*;class Date {private int year;private int month;private int day;public Date(int day, int month, int year) { //构造函数,构造方法this.year = year;this.month = month;this.day = day;} //end public MyDate(int y,int m,int d)public int getYear() { //返回年return year;} //end getYear()public int getMonth() { //返回月return month;} //end getMonth()public int getDay() { //返回日return day;} //end getDay()} //end class Datepublic class Teacher {String name;//教师名字boolean sex;//性别,true表示男性Date birth;//出生日期String salaryID;//工资号String depart;//教师所在系所String posit;//教师职称String getName() {return name;}void setName(String name) { = name;}boolean getSex() {return sex;}void setSex(boolean sex) {this.sex = sex;}Date getBirth() {return birth;}void setBirth(Date birth) {this.birth = birth;}String getSalaryID() {return salaryID;}void setSalaryID(String salaryID) {this.salaryID = salaryID;}String getDepart() {return depart;}void setDepart(String depart) {this.depart = depart;}String getPosit() {return posit;}void setPosit(String posit) {this.posit = posit;}public Teacher(){System.out.println("父类无参数的构造方法!!!!!!!"); }//如果这里不加上这个无参数的构造方法将会出错!!!!public Teacher(String name,boolean sex,Date birth,String salaryid,String depart,String posit){ =name;this.sex=sex;this.birth=birth;this.salaryID=salaryid;this.depart=depart;this.posit=posit;}//end Teacher()public void print(){System.out.print("the teacher'name:");System.out.println(this.getName());System.out.print("the teacher'sex:");if(this.getSex()==false){System.out.println("女");}else{System.out.println("男");}System.out.print("the teacher'birth:");System.out.println(this.getBirth().getYear()+"-"+this.getBirth().getMonth()+"-"+this.getBirth().getDay()); System.out.print("the teacher'salaryid:");System.out.println(this.getSalaryID());System.out.print("the teacher'posit:");System.out.println(this.getPosit());System.out.print("the teacher'depart:");System.out.println(this.getDepart());}//end print()public static void main(String[] args) {Date dt1=new Date(11,23,1989);Date dt2=new Date(2,6,1975);Date dt3=new Date(11,8,1964);Date dt4=new Date(10,4,1975);Date dt5=new Date(8,9,1969);//创建各系教师实例,用来测试Teacher t1=new Teacher("王莹",false,dt1,"123","经济学","prefessor");ResearchTeacher rt=new ResearchTeacher("杨zi青",true,dt2,"421","软件工程","associate prefessor","software");LabTeacher lat=new LabTeacher("王夏瑾",false,dt3,"163","外语","pinstrucor","speech lab");LibTeacher lit=new LibTeacher("马二孩",true,dt4,"521","大学物理","prefessor","physicalLib");AdminTeacher at=new AdminTeacher("王xi",false,dt5,"663","环境","prefessor","dean");/////////分别调用各自的输出方法,输出相应信息////////////////////////////System.out.println("-------------------------------");t1.print();//普通教师信息System.out.println("-------------------------------");rt.print();//研究系列教师信息System.out.println("-------------------------------");lat.print();//普通教师信息System.out.println("-------------------------------");lit.print();//实验系列教师信息System.out.println("-------------------------------");at.print();//行政系列教师信息System.out.println("-------------------------------");}//end main()}//end public class Teacherclass ResearchTeacher extends Teacher{private String resField;public ResearchTeacher(String name, boolean sex, Date birth, String salaryid,String depart, String posit, String resField) { = name;this.sex = sex;this.birth = birth;this.salaryID = salaryid;this.depart = depart;this.posit = posit;this.resField = resField;} //end public ResearchTeacher(){}String getResField(){return resField;}void setResField(String resField){this.resField=resField;}public void print() {System.out.print("research teacher info is:");System.out.print("the teacher'name:");System.out.println(this.getName());System.out.print("the teacher'sex:");if (this.getSex() == false) {System.out.println("女");}else {System.out.println("男");}System.out.print("the teacher'birth:");System.out.println(this.getBirth().getYear() + "-" +this.getBirth().getMonth() + "-" +this.getBirth().getDay());System.out.print("the teacher'salaryid:");System.out.println(this.getSalaryID());System.out.print("the teacher'posit:");System.out.println(this.getPosit());System.out.print("the teacher'depart:");System.out.println(this.getDepart());System.out.print("the teacher'resField:");System.out.println(this.getResField());} //end print()}//end class ResearchTeacherclass LabTeacher extends Teacher{private String labName;public LabTeacher(String name, boolean sex, Date birth,String salaryid, String depart,String posit, String labName) { = name;this.sex = sex;this.birth = birth;this.salaryID = salaryid;this.depart = depart;this.posit = posit;bName = labName;} //end public ResearchTeacher(){}String getLabName(){return labName;}void setLabName(String labName){bName=labName;}public void print() {System.out.print("lab teacher info is:");System.out.print("the teacher'name:");System.out.println(this.getName());System.out.print("the teacher'sex:");if (this.getSex() == false) {System.out.println("女");}else {System.out.println("男");}System.out.print("the teacher'birth:");System.out.println(this.getBirth().getYear() + "-" +this.getBirth().getMonth() + "-" +this.getBirth().getDay());System.out.print("the teacher'salaryid:");System.out.println(this.getSalaryID());System.out.print("the teacher'posit:");System.out.println(this.getPosit());System.out.print("the teacher'depart:");System.out.println(this.getDepart());System.out.print("the teacher'labName:");System.out.println(bName);} //end print()}//end class LabTeacherclass LibTeacher extends Teacher{private String libName;public LibTeacher(String name,boolean sex,Date birth,String salaryid,String depart,String posit,String libName){ = name;this.sex = sex;this.birth = birth;this.salaryID = salaryid;this.depart = depart;this.posit = posit;this.libName=libName;}//end public ResearchTeacher(){}String getLibName(){return libName;}void setLibName(String libName){this.libName=libName;}public void print() {System.out.print("lib teacher info is:");System.out.print("the teacher'name:");System.out.println(this.getName());System.out.print("the teacher'sex:");if (this.getSex() == false) {System.out.println("女");}else {System.out.println("男");}System.out.print("the teacher'birth:");System.out.println(this.getBirth().getYear() + "-" +this.getBirth().getMonth() + "-" +this.getBirth().getDay());System.out.print("the teacher'salaryid:");System.out.println(this.getSalaryID());System.out.print("the teacher'posit:");System.out.println(this.getPosit());System.out.print("the teacher'depart:");System.out.println(this.getDepart());System.out.print("the teacher'libName:");System.out.println(this.libName);} //end print()}//end class LibTeacherclass AdminTeacher extends Teacher{private String managePos;public AdminTeacher(String name,boolean sex,Date birth,String salaryid,String depart,String posit,String managePos){ = name;this.sex = sex;this.birth = birth;this.salaryID = salaryid;this.depart = depart;this.posit = posit;this.managePos=managePos;}//end public ResearchTeacher(){}String getManagePos(){return managePos;}void setManagePos(String managePos){this.managePos=managePos;}public void print() {System.out.print("adminteacher info is:");System.out.print("the teacher'name:");System.out.println(this.getName());System.out.print("the teacher'sex:");if (this.getSex() == false) {System.out.println("女");}else {System.out.println("男");}System.out.print("the teacher'birth:");System.out.println(this.getBirth().getYear() + "-" +this.getBirth().getMonth() + "-" +this.getBirth().getDay());System.out.print("the teacher'salaryid:");System.out.println(this.getSalaryID());System.out.print("the teacher'posit:");System.out.println(this.getPosit());System.out.print("the teacher'depart:");System.out.println(this.getDepart());System.out.print("the teacher'managePos:");System.out.println(this.managePos);} //end print()}//end class AdminTeacher习题2.11public class Course {private String courseID;private String courseName;private String courseType;private int classHour;private float credit;public Course(String courseID, String courseName, String courseType,int classHour, float credit) {this.courseID=courseID;this.courseName=courseName;this.courseType=courseType;this.classHour=classHour;this.credit=credit;}//end public Course(){}String getID() {return courseID;}void setID(String id) {this.courseID = id;}String getName() {return courseName;}void setName(String name) {this.courseName = name;}String getType() {return courseType;}void setType(String type) {this.courseType = type;}int getClassHour() {return classHour;}void setClassHour(int hour) {this.classHour = hour;}float getCredit() {return classHour;}void setCredit(float credit) {this.credit= credit;}public void print(){System.out.println("the basic info of this course as followed:");System.out.println("courseID="+this.getID());System.out.println("courseName="+this.getName());System.out.println("courseType="+this.getType());System.out.println("classHour="+this.getClassHour());System.out.println("credit="+this.getCredit());}public static void main(String[] args) {Course cs=new Course("d12","java程序设计(第二版)","cs",64,3.0f);System.out.println("----------------------------------");cs.print();System.out.println("修改课程学分为4.0f");cs.setCredit(4);cs.print();}}//习题2.12public class MyGraphic {String lineColor;String fillColor;MyGraphic(String lc,String fc){this.lineColor=lc;this.fillColor=fc;}void print(){System.out.println("line color is "+this.lineColor+"\t fill color is "+this.fillColor);}public static void main(String[] args) {float rd=(float)4.5;MyCircle mc=new MyCircle(rd,"black","white");MyRectangle mr=new MyRectangle(4,6,"red","blue");System.out.println("Circle info ");mc.print();System.out.println("circumference is " + mc.calCircum());System.out.println("square is " + mc.calSquare());System.out.println("rectangle info: ");mr.print();System.out.println("circumference is " + mr.calCircum());System.out.println("square is " + mr.calSquare());}//end main(){}}//end public class MyGraphicclass MyRectangle extends MyGraphic{float rLong;float rWidth;MyRectangle (float rl,float rw,String lc,String fc){super(lc,fc);this.rLong=rl;this.rWidth=rw;}//end MyRectangle (){}float calCircum(){return ((float)((this.rLong+this.rWidth)*2));}float calSquare(){return ((float)(this.rLong*this.rWidth));}}//end class MyRectangleclass MyCircle extends MyGraphic{float radius;MyCircle (float rd,String lc,String fc){super(lc,fc);this.radius=rd;}//end MyRectangle (){}float calCircum(){return (float)((this.radius*3.12*2));}float calSquare(){return ((float)(this.radius*this.radius*3.14));}}//end class MyCircle//习题2.13public class Vehicle {String brand;String color;int price;int number;public Vehicle(String b, String c) {this.brand = b;this.color = c;}public Vehicle(String b, String c, int p, int n) {this(b, c);this.price = p;this.number = n;}void print() {System.out.println("\n-------------------------");System.out.println("the vehicle info as followed :");System.out.println("brand=" + this.brand + "\t");System.out.println("color=" + this.color + "\t");System.out.println("price=" + this.price + "\t");System.out.println("number=" + this.number + "\t"); } //end void print()public static void main(String[] args) {V ehicle c1=new Vehicle("vehicle1","white");V ehicle c2=new Vehicle("vehicle2","white",300,1);Car cr=new Car("car1","red",300,4,400);Truck tk2=new Truck("truck1","black",300,400);c1.print();c2.print();cr.print();tk2.print();} //end main()} //end public class Vehicleclass Car extends Vehicle{int speed;Car(String b, String c, int p, int n,int s){super(b,c,p,n);this.speed=s;}void print(){super.print();System.out.print("speed="+this.speed); }}//end class Carclass Truck extends Vehicle{int speed;int weight;Truck(String b, String c, int s,int w){super(b,c);this.speed=s;this.weight=w;}void print(){super.print();System.out.print("speed="+this.speed);System.out.print("weight="+this.weight); }}//end class Truck//习题3.3public class Test {public static void main(String[] args) {int b1=1;int b2=1;System.out.println("b1=" + b1);System.out.println("b2=" + b2);b1<<=31;b2<<=31;System.out.println("b1=" + b1);System.out.println("b2=" + b2);b1 >>= 31;System.out.println("b1=" + b1);b1 >>= 1;System.out.println("b1=" + b1);b2 >>>= 31;System.out.println("b2=" + b2);b2 >>>= 1;System.out.println("b2=" + b2);}}//习题3.4public class Factorial {private int result,initVal;public static int Factorial(int n){if(n==0){return 1;}return n*Factorial(n-1);}public void print(){System.out.println(initVal+"!="+result); }public void setInitVal(int n){initVal=n;}public static void main(String[] args) {Factorial ff=new Factorial();for(int i=0;i<=4;i++){ff.setInitVal(2*(i+1));ff.result=Factorial(ff.initVal);ff.print();}//end for()}//end main()}//end public class Factorialpublic class Factorial2 {private int result,initVal;public void print(){System.out.println(initVal+"!="+result);}public void setInitVal(int n){initVal=n;}public static void main(String[] args) {Factorial2 ff=new Factorial2();for(int i=0;i<=4;i++){ff.setInitVal(2*(i+1));ff.result=1;for(int j=2;j<=ff.initV al;j++){ff.result*=j;}ff.print();}//end for()}//end main()}//习题3.5public class MathRandomTest {public static void main(String[] args) {int count=0,MAXof100,MINof100;int num,i;MAXof100=(int)(100*Math.random());MINof100=(int)(100*Math.random());System.out.print(MAXof100+" ");System.out.print(MINof100+" ");if(MAXof100>50)count++;if(MINof100>50)count++;if( MAXof100<MINof100){num=MINof100;MINof100=MAXof100;MAXof100=num;}//end if()for(i=0;i<98;i++){num=(int)(100*Math.random());System.out.print(num+((i+2)%10==9?"\n":" "));if(num>MAXof100){MAXof100=num;}else if(num<MINof100){MINof100=num;}if(num>50){count++;}}//end for()System.out.println("the max of 100 random integers is "+MAXof100);System.out.println("the min of 100 random integers is "+MINof100);System.out.println("the number of random more than50 is "+count); }//end main()}//end public class MathRandomTest//习题3.7public class PrintAst {public void printAstar() {System.out.print("*");}public void printSpace() {System.out.print(" ");}public static void main(String[] args) {PrintAst pa = new PrintAst();int initNum = 13;for (int i = 1; i <= initNum / 2 + 1; i++) {for (int n = 1; n <= i; n++) {pa.printSpace();pa.printSpace();}for (int m = 1; m <= initNum - 2 * i + 2; m++) {pa.printSpace();pa.printAstar();}System.out.println();} //end forif (initNum % 2 == 0) {for (int i = 1; i <= initNum / 2; i++) {pa.printSpace();pa.printSpace();}pa.printSpace();pa.printAstar();pa.printSpace();pa.printAstar();System.out.println();}for (int i = initNum / 2 + 2; i <= initNum; i++) {for (int n = 1; n <= initNum - i + 1; n++) {pa.printSpace();pa.printSpace();}for (int m = 1; m <= 2 * i - initNum; m++) {pa.printSpace();pa.printAstar();}System.out.println();} //end forSystem.out.println();} //end main()} //end public class PrintAst//习题3.8public class PrintTriag {public void printAstar() {System.out.print("*");}public static void main(String[] args) {int initLine = 10;int initNum = 10;PrintTriag pt = new PrintTriag();for (int i = 0; i < initLine; i++) {for (int j = 0; j < initNum - i; j++) {pt.printAstar();}System.out.println();}}//end main()}//end public class PrintTriag习题3.9import java.util.*;public class MultipleTable {public void printFormula(int i,int j,int res){System.out.print(i+"*"+j+"="+res+" "); }public static void main(String[] args) {MultipleTable mt=new MultipleTable();int initNum=9;int res=0;for(int i=1;i<=initNum;i++){for(int j=1;j<=i;j++){res=i*j;mt.printFormula(i,j,res);}System.out.println();}//end for}//end main()}//end public class MultipleTable习题3.10import java.io.*;public class HuiWen {boolean isHuiWen(char str[], int n) {int net = 0;int i, j;for (i = 0, j = n - 1; i < n / 2; i++, j--) {if (str[i] == str[j]) {net++;} //end if} //end forif (net == (int) (n / 2)) {return true;} //end ifelse {return false;}} //end boolean isHuiWen(char str[], int n)public static void main(String[] args) {HuiWen hw1 = new HuiWen();String pm = "";try {InputStreamReader reader = new InputStreamReader(System.in);BufferedReader input = new BufferedReader(reader);System.out.print("give your test string:\n");pm = input.readLine();System.out.println(pm);} //end trycatch (IOException e) {System.out.print(e);} //end catchboolean bw = hw1.isHuiWen(pm.toCharArray(), pm.length());if (bw == true) {System.out.println("是回文");}else {System.out.println("不是回文");}} //end main()} //end public class HuiWenimport java.io.*;public class HuiWen2 {String reverse(String w1){String w2;char[]str1=w1.toCharArray();int len=w1.length();char[]str2=new char[len];for(int i=0;i<len;i++){str2[i]=str1[len-1-i];}w2=new String(str2);return w2;}public static void main(String[] args) {HuiWen2 hw1 = new HuiWen2();String pm = "";try {InputStreamReader reader = new InputStreamReader(System.in);BufferedReader input = new BufferedReader(reader);System.out.print("give your test string:\n");pm = input.readLine();} //end trycatch (IOException e) {System.out.print(e);} //end catchString w2=hw1.reverse(pm);if(pareTo(pm)==0){System.out.println("是回文");}else {System.out.println("不是回文");}}}//习题3.11import java.io.*;public class PrimeNumber {private int pm;public void setPm(int pm){this.pm=pm;}public boolean isPrime(){boolean bl=true;int i=2;for(i=2;i<=Math.sqrt(pm);){if(pm%i==0){bl=false;break;}else{i++;}}//end forreturn bl;}//end public boolean isPrime()public static void main(String[] args) {PrimeNumber prim=new PrimeNumber();int testNum=0;try{InputStreamReader reader = new InputStreamReader(System.in);BufferedReader input = new BufferedReader(reader);System.out.print("give your test number:\n");testNum=Integer.parseInt(input.readLine());}//end trycatch(IOException e){System.out.println(e);}//end catchprim.setPm(testNum);boolean bl=prim.isPrime();if(bl==true){System.out.println(testNum+"是质数");}else {System.out.println(testNum+"不是质数");}}//end main}//end public class PrimeNumber习题3.12import java.io.*;public class Tempconverter {double celsius(double y){return ((y-32)/9*5);}public static void main(String[] args) {Tempconverter tc=new Tempconverter ();double tmp=0;try{InputStreamReader reader = new InputStreamReader(System.in);BufferedReader input = new BufferedReader(reader);System.out.print("give your fahrenheit number:\n");tmp=Double.parseDouble(input.readLine());}//end trycatch(NumberFormatException e){System.out.println(e);}//end catchcatch(IOException e){System.out.println(e);}//end catchSystem.out.println("the celsius of temperature is "+tc.celsius(tmp));}//end main()}//end public class Tempconverter习题3.13import java.io.*;public class Trigsquare {double x, y, z;Trigsquare(double x, double y, double z) {this.x = x;this.y = y;this.z = z;}boolean isTriangle() {boolean bl = false;if (this.x > 0 && this.y > 0 && this.z > 0) {if ( (this.x + this.y) > this.z && (this.x + this.z) > this.y && (this.z + this.y) > this.x) {bl = true;} //ebd ifelse {bl = false;} //end else} //end if(this.x>0&&this.y>0&&this.z>0)return bl;} //end boolean isTriangle()double getArea() {double s = (this.x + this.y + this.z) / 2.0;return (Math.sqrt(s * (s - this.x) * (s - this.y) * (s - this.z)));} //end double getArea()public static void main(String[] args) {double s[] = new double[3];try {InputStreamReader reader = new InputStreamReader(System.in);BufferedReader input = new BufferedReader(reader);System.out.print("输入三角形的三边的长度:\n");。
计算机国外著名教材列表
作者:
作者:Kip R. Irvine
其他影印版图书
C++ Network Programming, Volume 1: Mastering Complexity with ACE and Patterns C++网络编程, 卷1: 运 用ACE和模式消除复杂 性 ISBN:7-302-07644-8 作者:Douglas C. Schmidt Stephen D. Huston 定价:29.00元 Computing Concepts 新概念计算机英语 ISBN:7-302-07357-0 作者:Stephen Haag Maeve Cummings Alan I Rea, Jr 定价:52.00元 C++ Network Programming, Volume 2: Systematic Reuse with ACE and Frameworks C++网络编程,卷2: 基 于ACE和框架的系统 化复用 ISBN:7-302-07964-1 作者:Douglas C. Schmidt Stephen D. Huston 定价:34.00元
Reference, Fourth Edition C++完全参考手册(第 4版) 作者:Herbert Schildt ISBN 7-302-10157-4 定价:96.00元 Parallel Programming: in C with MPI and OpenMP 并行程序设计: C、MPI 与OpenMP 作者:Michael J. Qiunn ISBN 7-302定价:元 Fundamentals of Algorithmics 算法基础 作者:Gilles Brassard, Paul Bratley ISBN 7-302定价:元 Business Data Communications, 5E 事务数据通信(第5 版) 作者:William Stallings ISBN 7-302定价:元 即将出版 Classic and Contemporary Cryptology 经典密码学与现代密码 学 作者:Richard J. Spillman Object-Oriented Programming in C++, 2E C++面向对象程序设计 (第2版) 作者:Richard Johnsonbaugh, Martin Kalin Assembly Language for Intel-Based Computers, 4E Intel汇编语言程序设计 (第4版)
《Java程序设计》课程教学大纲
《Java程序设计》课程教学大纲课程编号:08120031课程名称:Java程序设计/JAVA Programming总学时/学分:48/3(其中理论32学时,实验16学时)适用专业:计算机科学与技术一、课程目标通过本课程学习,学生应达到如下目标:目标1. 识别Java语言特点、基本语法、语言机制。
目标2. 将面向对象方法知识运用在程序设计案例中,能使用JAVA常用类、枚举、lambda 表达式、容器、泛型进行实例编程验证。
目标3. 利用JavaSE中的异常处理、输入输出等技术来表达处理程序应用问题。
目标4. 将图形用户界面和数据库编程技术运用中综合应用程序设计中。
目标5. 搭建Java开发环境,能设计实现各种Java技术的应用程序,且能测试运行。
二、课程目标对毕业要求的支撑三、教学过程安排四、实验或上机内容五、课程目标达成方法六、考核标准本门课程考核包括6个部分,分别为考试、作业、实验、讨论和测验。
具体要求及评分方法如下:1、期末考试试卷知识点要求2、作业3、实验4、讨论设置讨论课一次,要求学生按照讨论题目分组查阅资料,归纳总结,撰写报告。
5、测验随堂测验,老师给出题目,学生回答。
具体有任课老师给出评分标准。
七、教材及主要参考资料[1] 黑马程序员. Java基础入门(第2版)[M]. 清华大学出版社, 2018.[2] 郑人杰、马素霞、殷人昆. 软件工程概论(第2版)[M]. 机械工业出版社,2016.[3] Gay S.Horstmann. Java核心技术(第10版)[M]. 机械工业出版社,2016.[4] Y.Daniel Liang(美). Java语言程序设计(第10版)[M]. 机械工业出版社.2015.[5] 李刚. 疯狂Java讲义(第4版)[M]. 电子工业出版社,2018.[6] 封亚飞. 揭秘Java虚拟机[M]. 电子工业出版社,2017.[7] Bruce Eckel(美). Java编程思想(第4版)[M]. 机械工业出版社,2007.。
《Java程序设计》(唐大仕)课后习题答案
第1章 Java语言面与向对象的程序设计1. Java语言有哪些主要特点?答:〔要点〕:1.简单易学2.面向对象3.平台无关性4.安全稳定5.支持多线程6.很好地支持网络编程7.Java丰富的类库使得Java可以广泛地应用2.简述面向过程问题求解和面向对象问题求解的异同。
试列举出面向对象和面向过程的编程语言各两种。
答:面向过程问题求解,以具体的解题过程为研究和实现的主体,其思维特点更接近于电脑;面向对象的问题求解,则是以“对象”为主体,“对象”是现实世界的实体或概念在电脑逻辑中的抽象表示,更接近于人的思维特点。
面向过程的编程语言:C,Pascal,Foratn。
面向对象的编程语言:C++,Java,C#。
3.简述对象、类和实体及它们之间的相互关系。
尝试从日常接触到的人或物中抽象出对象的概念。
答:面向对象技术中的对象就是现实世界中某个具体的物理实体在电脑逻辑中的映射和表达。
类是同种对象的集合与抽象。
类是一种抽象的数据类型,它是所有具有一定共性的对象的抽象,而属于类的某一个对象则被称为是类的一个实例,是类的一次实例化的结果。
如果类是抽象的概念,如“电视机”,那么对象就是某一个具体的电视机,如“我家那台电视机”。
4.对象有哪些属性?什么是状态?什么是行为?二者之间有何关系?设有对象“学生”,试为这个对象设计状态与行为。
答:对象都具有状态和行为。
对象的状态又称为对象的静态属性,主要指对象内部所包含的各种信息,也就是变量。
每个对象个体都具有自己专有的内部变量,这些变量的值标明了对象所处的状态。
行为又称为对象的操作,它主要表述对象的动态属性,操作的作用是设置或改变对象的状态。
学生的状态:、性别、年龄、所在学校、所在系别、通讯地址、号码、入学成绩等;学生的行为:自我介绍、入学注册、选课、参加比赛等。
5.对象间有哪三种关系?对象“班级”与对象“学生”是什么关系?对象“学生”与对象“大学生”是什么关系?答:对象间可能存在的关系有三种:包含、继承和关联。
java语言程序设计-基础篇-课件(第3章)英文
4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 Set3
8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 Set4
16 20 24 28
17 21 25 29
18 22 26 30
19 23 27 31
Set2
Set5
7
if (boolean-expression) { statement(s); }
if (radius >= 0) { area = radius * radius * PI; System.out.println("The area" + " for the circle of radius " + radius + " is " + area); }
2 10 18 26
3 11 15 23 31
4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 Set3
2
If you assigned a negative value for radius in Listing 2.1, ComputeArea.java, the program would print an invalid result. If the radius is negative, you don't want the program to compute the area. How can you deal with this situation?
(b)
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807
java语言程序设计 进阶篇 原书第八版 课件 PPT(第四十三章)
8
Passing Parameters, cont.
Remote object type. Remote objects are passed differently from the local objects. When a client invokes a remote method with a parameter of some remote object type, the stub of the remote object is passed. The server receives the stub and manipulates the parameter through the stub.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807
4
The Differences between RMI and Traditional Client/Server Approach
Chapter 43 Remote Method Invocation
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807
《Java语言程序设计双语》
《Java语言程序设计(双语)》(Programming with Java)(学时: 50)一、简要说明:《Java语言程序设计(双语)》是软件工程、计算机科学与技术及信息类专业的专业选修课;本课程3.0个学分,共50学时,其中上机实验10个学时。
二、课程教学目的设置本课程的主要目的是通过对Java语言的语法规则、数据类型、虚拟机、流程控制、类与对象、多态性等内容的讲授,让学生掌握应用Java语言进行程序设计的技能,牢固掌握面向对象程序设计的思想,为进行各种实用程序开发奠定一个良好的基础。
同时,该课程采用英文原版教材,以Java知识的教学为载体,为学生创造一种学习计算机知识的英文环境,使学生能用英语进行程序设计方面的交流,培养学生运用英语进行思维的习惯。
该课程也是《J2EE与中间件》等后续课程的先修课。
三、教学基本要求和方法本课程的理论教学部分主要采用课堂讲解及多媒体辅助教学,多媒体包括幻灯片,相关的声像资料及图片资料等。
实践教学部分通过上机实验、作品设计和案例编程等方法提高学生实际编程能力。
四、课程考核方式本门课程成绩采用百分制计分。
作为考试改革试点课程,提高平时成绩在总成绩中的比重,注重平时实践和综合能力的培养。
期末笔试成绩拟占总成绩的40%-50%,平时实践、综合设计成绩占总成绩的50%-60%。
采用闭卷笔试、作品设计及平时实践等相结合的多元考核方式。
在笔试中注重考核学生思维能力以及知识灵活应用能力,减少记忆知识的考核;在平时实践和作品设计中重点考查学生学以致用和综合思考的能力,并鼓励个性化设计及创新精神。
五、授课教材及主要参考书目授课教材:《Java语言程序设计基础篇(英文版第8版)》,(原书名:《Introduction to Java Programming》)(美)Y.Daniel Liang著,机械工业出版社,2012.1主要参考书目:《Java语言程序设计进阶篇(英文版第8版)》,(美)Y.Daniel Liang著,机械工业出版社,2012 《Java大学基础教程(英文影印版》,(原书名《Small Java How to Program Sixth Edition》),(美)Harvey M.Deitel,Paul J.Deitel,电子工业出版社,北京六、教学内容及学时分配(一)理论教学内容(40学时)Chapter 1 Introduction to Computers,Programs,and Java (2学时)1、目的要求:To review computer basics, programs, and operating systems (§§1.2-1.4).To explore the relationship between Java and the World Wide Web (§1.5).To distinguish the terms API, IDE, and JDK (§1.6).To write a s imple Java program (§1.7).To display output on the console (§1.7).To explain the basic syntax of a Java program (§1.7).To create, compile, and run Java programs (§1.8).(GUI) To display output using the JOptionPane output dialog boxes (§1.9).2、要点(或讲授内容)1.1Introduction1.2What Is a Computer?1.3Programs1.4 Operating Systems1.5 Java, World Wide Web, and Beyond1.6The Java Language Specification, API, JDK, and IDE1.7A Simple Java Program1.8 Creating, Compiling, and Executing a Java Program1.9(GUI) Displaying Text in a Message Dialog BoxChapter 2 Elementary Programming(2学时)1、目的要求To write Java programs to perform simple calculations (§2.2).To obtain input from the console using the Scanner class (§2.3).To use identifiers to name variables, constants, methods, a nd classes (§2.4).To use variables to store data (§§2.5-2.6).To program with assignment statements and assignment expressions (§2.6).To use constants to store permanent data (§2.7).To declare Java primitive data types: byte, short, int, long, float, double, and char (§§2.8.1).To use Java operators to write numeric expressions (§§2.8.2–2.8.3).To display current time (§2.9).To use short hand operators (§2.10).To cast value of one type to another type (§2.11).To compute loan payment (§2.12).To repres ent characters using the char type (§2.13).To compute monetary changes (§2.14).To represent a string using the String type (§2.15).To become familiar with Java documentation, programming style, and naming conventions (§2.16).To distinguish syntax error s, runtime errors, and logic errors and debug errors (§2.17).(GUI) To obtain input using the JOptionPane input dialog boxes (§2.18).2、要点(或讲授内容)2.1Introduction2.2Writing Simple Programs2.3Reading Input from the Console2.4 Identifiers2.5Variables2.6Assignment Statements and Assignment Expressions2.7Named Constants2.8 Numeric Data Types and Operations2.9Problem: Displaying the Current Time2.10 Shorthand Operators2.11 Numeric Type Conversions2.12Problem: Computing Loan Payments2.13 Character Data Type and Operations2.14 Problem: Counting Monetary Units2.15The String Type2.16 Programming Style and Documentation2.17Programming Errors2.18 (GUI) Getting Input from Input DialogsChapter 3 Selections(2学时)1、目的要求:To declare boolean type and write Boolean expressions using comparison operators (§3.2).To program AdditionQuiz using Boolean expressions (§3.3).To implement selection control using one-way if statements (§3.4)To program the GuessBirthday game using one-way if statements (§3.5).To implement selection control using two-way if statemen ts (§3.6).To implement selection control using nested if statements (§3.7).To avoid common errors in if statements (§3.8).To program using selection statements for a variety of examples (BMI, ComputeTax, SubtractionQuiz) (§3.9-3.11).To generate random numbers using the m() method (§3.9).To combine conditions using logical operators (&&, ||, and !) (§3.12).To program using selection statements with combined conditions (LeapYear, Lottery) (§§3.13-3.14).To implement selection control using switch statem ents (§3.15).To write expressions using the conditional operator (§3.16).To format output using the .printf method and to format strings using the t method (§3.17).To examine the rules governing operator precedence and associativity (§3.18).(GUI) To get user confirmation using confirmation dialogs (§3.19).2、要点:3.1Introduction3.2boolean Data Type3.3Problem: A Simple Math Learning Tool3.4 if Statements3.5Problem: Guessing Birthdays3.6 Two-Way if Statements3.7 Nested if Statements3.8 Common Errors in Selection Statements3.9 Problem: An Improved Math Learning Tool3.10 Problem: Computing Body Mass Index3.11Problem: Computing Taxes3.12 Logical Operators3.13Problem: Determining Leap Year3.14Problem: Lottery3.15 switch Statements3.16Conditional Expressions3.17 Formatting Console Output3.18Operator Precedence and Associativity3.19 (GUI) Confirmation DialogsChapter 4 Loops(2学时)1、目的要求:To write programs for executing statements repeatedly using a while loop (§4.2).To develop a program for GuessNumber and SubtractionQuizLoop (§4.2.1).To foll ow the loop design strategy to develop loops (§4.2.2).To develop a program for SubtractionQuizLoop (§4.2.3).To control a loop with a sentinel value (§4.2.3).To obtain large input from a file using input redirection rather than typing from the keyboard (§4.2.4).To write loops using do-while statements (§4.3).To write loops using for statements (§4.4).To discover the similarities and differences of three types of loop statements (§4.5).To write nested loops (§4.6).To learn the techniques for minimizin g numerical errors (§4.7).To learn loops from a variety of examples (GCD, FutureTuition, MonteCarloSimulation) (§4.8).To implement program control with break and continue (§4.9).(GUI) To control a loop with a confirmation dialog (§4.10).2、要点:4.1 Introduction4.2 The whileLoop4.3 The do-while Loop4.4 The for Loop4.5 Which Loop to Use?4.6 Nested Loops4.7 Minimizing Numeric Errors4.8 Case Studies4.9 Keywords breakand continue4.10 (GUI) Controlling a Loop with a Confirmation DialogChapter 5 Methods(2学时)1、目的要求:To define methods, invoke methods, and pass arguments to a method (§5.2-5.5).To develop reusable code that is modular, easy-to-read, easy-to-debug, and easy-to-maintain. (§5.6).To use method overloading and understand ambiguous ov erloading (§5.7).To design and implement overloaded methods (§5.8).To determine the scope of variables (§5.9).To know how to use the methods in the Math class (§§5.10-5.11).To learn the concept of method abstraction (§5.12).To design and implement met hods using stepwise refinement (§5.12).2、要点:5.1 Introduction5.2 Defining a Method5.3 Calling a Method5.4 void Method Example5.5 Passing Parameters by Values5.6 Modularizing Code5.7 Problem: Converting Decimals to Hexadecimals5.8 Overloading Methods5.9 The Scope of Variables5.10 The Math Class5.11 Case Study: Generating Random Characters5.12 Method Abstraction and Stepwise RefinementChapter 6 Single-Dimensional Arrays(1学时)1、目的要求:To describe why arrays are necessary in programming (§6.1).To declare array reference variables and create arrays (§§6.2.1-6.2.2).To initialize the values in an array (§6.2.3).To access array elements using indexed variables (§6.2.4).To declare, create, and initialize an array using an array initialize r (§6.2.5).To program common array operations (displaying arrays, summing all elements, finding min and max elements, random shuffling, shifting elements) (§6.2.6).To simplify programming using the for-each loops (§6.2.7).To apply arrays in the LottoNumbers and DeckOfCards problems (§§6.3-6.4).To copy contents from one array to another (§6.5).To develop and invoke methods with array arguments and return value (§6.6–6.7).To define a method with variable-length argument list (§6.8).To search elements using the linear (§6.9.1) or binary (§6.9.2) search algorithm.To sort an array using the selection sort (§6.10.1)To sort an array using the insertion sort algorithm (§6.10.2).To use the methods in the Arrays class (§6.11).2、要点:6.1 Introduction6.2 Array Basics6.3 Problem: Lotto Numbers6.4 Problem: Deck of Cards6.5 Copying Arrays6.6 Passing Arrays to Methods6.7 Returning an Array from a Method6.8 Variable-Length Argument Lists6.9 Searching Arrays6.10 Sorting Arrays6.11 The ArraysChapter 7 Multidimensional Arrays(1学时)1、目的要求:To give examples of representing data using two-dimensional arrays (§7.1).To declare variables for two-dimensional arrays, create arrays, and access array elements ina two-dimensional array using row and colu mn indexes (§7.2).To program common operations for two-dimensional arrays (displaying arrays, summing all elements, finding min and max elements, and random shuffling) (§7.3).To pass two-dimensional arrays to methods (§7.4).To write a program for grading multiple-choice questions using two-dimensional arrays (§7.5).To solve the closest-pair problem using two-dimensional arrays (§7.6).To check a Sudoku solution using two-dimensional arrays (§7.7).To use multidimensional arrays (§7.8).2、要点:7.1 Introduction7.2 Two-Dimensional Array Basics7.3 Processing Two-Dimensional Arrays7.4 Passing Two-Dimensional Arrays to Methods7.5 Problem: Grading a Multiple-Choice Test7.6 Problem: Finding a Closest Pair7.7 Problem: Sudoku7.8 Multidimensional ArraysChapter 8 Objects and Classes(2学时)1、目的要求:To describe objects and classes, and use classes to model objects (§8.2).To use UML graphical notations to describe classes and objects (§8.2).To demonstrate defining classes and creating objects (§8.3).T o create objects using constructors (§8.4).To access objects via object reference variables (§8.5).To define a reference variable using a reference type (§8.5.1).To access an object’s data and methods using the object member access operator (.) (§8.5.2).To define data fields of reference types and assign default values for an object’s data fields (§8.5.3).To distinguish between object reference variables and primitive data type variables (§8.5.4).To use classes Date, Random, and JFrame in the Java lib rary (§8.6).To distinguish between instance and static variables and methods (§8.7).To define private data fields with appropriate get and set methods (§8.8).To encapsulate data fields to make classes easy to maintain (§8.9).To develop methods with object arguments and differentiate between primitive-type arguments and object-type arguments (§8.10).To store and process objects in arrays (§8.11).2、要点:8.1 Introduction8.2 Defining Classes for Objects8.3 Example: Defining Classes and Creating Objects8.4 Constructing Objects Using Constructors8.5 Accessing Objects via Reference Variables8.6 Using Classes from the Java Library8.7 Static Variables, Constants, and Methods8.8 Visibility Modifiers8.9 Data Field Encapsulation8.10 Passing Objects to Methods8.11 Array of ObjectsChapter 9 Strings and Text I/O(2学时)1、目的要求:To use the String class to process fixed strings (§9.2).To use the Character class to process a single character (§9.3).To use the StringBuilder/StringBuffer class to proces s flexible strings (§9.4).To distinguish among the String, StringBuilder, and StringBuffer classes (§9.2-9.4).To learn how to pass arguments to the main method from the command line (§9.5).To discover file properties and to delete and rename files using the File class (§9.6).To write data to a file using the PrintWriter class (§9.7.1).To read data from a file using the Scanner class (§9.7.2).(GUI) To open files using a dialog box (§9.8)2、要点:9.1 Introduction9.2 The String Class9.3 The Character Class9.4 The StringBuilder /StringBuffer Class9.5 Command-Line Arguments9.6 The File Class9.7 File Input and Output9.8 (GUI) File DialogsChapter 10 Thinking in Objects(2学时)1、目的要求:To create immutable objects from immutable classes to protect t he contents of objects (§10.2).To determine the scope of variables in the context of a class (§10.3).To use the keyword this to refer to the calling object itself (§10.4).To apply class abstraction to develop software (§10.5).To explore the differences between the procedural paradigm and object-oriented paradigm (§10.6).To develop classes for modeling composition relationships (§10.7).To design programs using the object-oriented paradigm (§§10.8-10.10).To design classes that follow the class-design guidelines (§10.11).2、要点:10.1 Introduction10.2 Immutable Objects and Classes10.3 The Scope of Variables10.4 The this Reference10.5 Class Abstraction and Encapsulation10.6 Object-Oriented Thinking10.7 Object Composition10.8 Designing the Course Class10.9 Designing a Class for Stacks10.10 Designing the GuessDate Class10.11 Class Design GuidelinesChapter 11 Inheritance and Polymorphism(4学时)1、目的要求:To develop a subclass from a superclass through inheritance (§11.2).To invoke the supe rclass’s constructors and methods using the super keyword (§11.3).To override instance methods in the subclass (§11.4).To distinguish differences between overriding and overloading (§11.5).To explore the toString() method in the Object class (§11.6).To discover polymorphism and dynamic binding (§§11.7-11.8).To describe casting and explain why explicit downcasting is necessary (§11.9).To explore the equals() method in the Object class (§11.10).To store, retrieve, and manipulate objects in an ArrayList (§11.11).To implement a Stack class using ArrayList (§11.12).To restrict access to data and methods to subclasses using the protected visibility modifier (§11.13).To prevent class extending and method overriding using the final modifier (§11.14).2、要点:11.1 Introduction11.2 Superclasses and Subclasses11.3 Using the superKeyword11.4 Overriding Methods11.5 Overriding vs. Overloading11.6 The Object Class and Its toString()Method11.7 Polymorphism11.8 Dynamic Binding11.9 Casting Objects and the instanceofOperator11.10 The Object ‘s equals() Method11.11 The ArrayList Class11.12 A Custom Stack Class11.13 The protected Data and Methods11.14 Preventing Extending and OverridingChapter 12 Gui Basics(2学时)1、目的要求:To distinguish betwe en Swing and AWT (§12.2).To describe the Java GUI API hierarchy (§12.3).To create user interfaces using frames, panels, and simple GUI components (§12.4).To understand the role of layout managers (§12.5).To use the FlowLayout, GridLayout, and BorderLayout managers to layout components in acontainer (§12.5).To use JPanel as subcontainers (§12.7).To specify colors and fonts using the Color and Font classes (§§12.7-12.8).To apply common features such as borders, tool tips, fonts, and colors on Swing components (§12.9).To use borders to visually group user-interface components (§12.9).To create image icons using the ImageIcon class (§12.10).2、要点:12.1 Introduction12.2 Swing vs. AWT12.3 The Java GUI API12.4 Frames12.5 Layout Managers12.6 Using Panels as Subcontainers12.7 The ColorClass12.8 The Font Class12.9 Common Features of Swing GUI Components12.10 Image IconsChapter 13 Exception Handling(2学时)1、目的要求:To get an overview of exceptions and exception handling (§13.2).To explore t he advantages of using exception handling (§13.3).To distinguish exception types: Error (fatal) vs. Exception (nonfatal), and checked vs.unchecked (§13.4).To declare exceptions in a method header (§13.5.1).To throw exceptions in a method (§13.5.2).To write a try-catch block to handle exceptions (§13.5.3).To explain how an exception is propagated (§13.5.3).To use the finally clause in a try-catch block (§13.6).To use exceptions only for unexpected errors (§13.7).To rethrow exceptions in a catch bl ock (§13.8).To create chained exceptions (§13.9).To define custom exception classes (§13.10).2、要点:13.1 Introduction13.2 Exception-Handling Overview13.3 Exception-Handling Advantages13.4 Exception Types13.5 More on Exception Handling13.6 The finallyClause13.7 When to Use Exceptions13.8 Rethrowing Exceptions13.9 Chained Exceptions13.10 Creating Custom Exception ClassesChapter 14 Abstract Classes and Interfaces(4学时)1、目的要求:To design and use abstract classes (§14.2).To process a calen dar using the Calendar and GregorianCalendar classes (§14.3).To specify common behavior for objects using interfaces (§14.4).To define interfaces and define classes that implement interfaces (§14.4).To define a natural order using the Comparable interfa ce (§14.5).To enable objects to listen for action events using the ActionListener interface (§14.6).To make objects cloneable using the Cloneable interface (§14.7).To explore the similarities and differences between an abstract class and an interface(§14.8).To create objects for primitive values using the wrapper classes (Byte, Short, Integer, Long, Float, Double, Character, and Boolean) (§14.9).To create a generic sort method (§14.10).To simplify programming using automatic conversion between primitive types and wrapper class types (§14.11).To use the BigInteger and BigDecimal classes for computing very large numbers with arbitrary precisions (§14.12).To design the Rational class for defining the Rational type (§14.13).2、要点:14.1 Introduction14.2 Abstract Classes14.3 Example: Calendar and GregorianCalendar14.4 Interfaces14.5 Example: The ComparableInterface14.6 Example: The ActionListener Interface14.7 Example: The Cloneable Interface14.8 Interfaces vs. Abstract Classes14.9 Processing Primitive Data Type Values as Objects14.10 Sorting an Array of Objects14.11 Automatic Conversion between Primitive Types and Wrapper Class Types14.12 The BigIntegerand BigDecimalClasses14.13 Case Study: The Rational ClassChapter 15 Graphics(2学时)1、目的要求:To describe Java coordinate systems in a GUI component (§15.2).To draw things using the methods in the Graphics class (§15.3).To override the paintComponent method to draw things on a GUI component (§15.3).To use a panel as a canvas to draw things (§15.3).To draw strings, lines, rectangles, ovals, arcs, and polygons (§§15.4, 15.6-15.7).To obtain font properties using FontMetrics and know how to center a message (§15.8).To display an image in a GUI component (§15.11).To develop reusable GUI components FigurePanel, MessagePanel, StillClock, and ImageViewer (§§15.5, 15.9, 15.10, 15.12).2、要点:15.1 Introduction15.2 Graphical Coordinate Systems15.3 The Graphics Class15.4 Drawing Strings, Lines, Rectangles, and Ovals15.5 Case Study: The FigurePanel Class15.6 Drawing Arcs15.7 Drawing Polygons and Polylines15.8 Centering a String Using the FontMetrics Class15.9 Case Study: The MessagePanelClass15.10 Case Study: The StillClockClass15.11 Displaying Images15.12 Case Study: The ImageViewer ClassChapter 16 Event-Driven Programming(2学时)1、目的要求:To describe events, event sources, and event classes (§16.2).To define listener classes, register listener objects with the source object, and write the code to handle events (§16.3).To define listener classes using inner classes (§16.4).To define listener classes using anonymous inner classes (§16.5).To explore various coding styles for creating and registering listeners (§16.6).To get input from text field upon clicking a button (§16.7).To write programs to deal with WindowEvent (§16.8).To simplify coding for listener classes using listener interface adapters (§16.9).To write programs to deal with MouseEvent (§16.10).To write programs to deal with KeyEvent (§16.11).To use the .Timer class to control animations (§16.12).2、要点:16.1 Introduction16.2 Event and Event Source16.3 Listeners, Registrations, and Handling Events16.4 Inner Classes16.5 Anonymous Class Listeners16.6 Alternative Ways of Defining Listener Classes16.7 Problem: Loan Calculator16.8 Window Events16.9 Listener Interface Adapters16.10 Mouse Events16.11 Key Events16.12 Animation Using the TimerClassChapter 17 Creating Graphical User Interfaces(4学时)1、目的要求:To create graphical user interfaces with various user-interface components: JButton, JCheckBox, JRadioButton, JLabel, JTextField, JTextArea, JComboBox, JList, JScrollBar, and JSlider(§§17.2–17.11).To create listeners for various types of events (§§17.2–17.11).To explore JButton (§17.2)To explore JCheckBox (§17.3)To explore JRadioButton (§17.4)To explore JLabel (§17.5)To explore JTextField (§17.6)To explore JTextArea (§17.7)To explore JComboBox (§17.8)To explore JList (§17.9)To explore JScrollBar (§17.10)To explore JSlider (§17.11)To display multiple windows in an application (§17.12).2、要点:17.1 Introduction17.2 Buttons17.3 Check Boxes17.4 Radio Buttons17.5 Labels17.6 Text Fields17.7 Text Areas17.8 Combo Boxes17.9 Lists17.10 Scroll Bars17.11 Sliders17.12 Creating Multiple WindowsChapter 19 Binary I/O(2学时)1、目的要求:To discover how I/O is processed in Java (§19.2).To distinguish between text I/O and binary I/O (§19.3).To read and write bytes using FileInputStream and FileOutputStream (§19.4.1).To read and write primitive values and strings using DataInputStream/DataOutputStream(§19.4.3).To store and restore objects using ObjectOutputStream and ObjectInputStream, and to understand how objects are serialized and what kind of objects can be serialized (§19.6).To implement the Serializable interface to make objects serializable (§19.6.1).To serialize arrays (§19.6.2).To read and write the same file using the RandomAccessFile class (§19.7).2、要点:19.1 Introduction19.2 How is I/O Handled in Java?19.3 Text I/O vs. Binary I/O19.4 Binary I/O Classes19.5 Problem: Copying Files19.6 Object I/O19.7 Random-Access Files(二)实验教学内容(10学时)实验一:Control Statements(2学时)1、实验目的:●Be familiar with JAVA developing environment●Grasp switch statements and loop statements2、实验方法:学生根据实验内容和实验要求,在老师的指导下设计、编译、调试、运行程序。
《Java语言程序设计》课程教学大纲
《Java语言程序设计》(第三版)课程教学大纲学分:4学分学时:72学时(其中:讲课学时:54 上机学时:27 )先修课程:计算机基础后续课程:《Java Web开发实战》适用专业:信息及其计算机相关专业开课部门:计算机系一、课程的性质与目标《Java语言程序设计》(第三版)是面向计算机相关专业的一门专业基础课,涉及Java语言中面向对象编程、多线程处理、网络通信以及程序设计模式等内容,课程具有较强的理论性、实用性和可操作性。
目的在于使学生了解Java语言特征、常用的Java API以及面向对象程序设计思想。
任务是使学生打下良好的Java基础,能够使用Java 语言编写简单的应用程序,并培养学生综合分析、设计并开发程序的能力。
二、课程设计理念与思路课程设计理念:Java程序设计课程是软件工程方向的重要基础课程。
课程设计上践行理论和实践一体化教学,理论与实践紧密联系。
本着懂理论、重应用的总体思路,突出体现高等职业教育技能型、应用性的特色,以实践教学为中心,以培养职业能力为根本,不局限于单纯的技能训练,使学生在完成案例的过程中,掌握专业知识和解决问题的能力。
课程设计思路:针对该课程的传统教学方法以理论应试为目的,难以适应培养企业IT人才的迫切需要的问题,在分析Java程序设计课程内容特点的基础上,在本课程中尝试使用真实项目贯穿整个教学过程,在演示案例上也尽可能使用具有前沿性的素材,使学生尽快熟悉并逐步掌握Java语言,进而让学生学会使用Java语言解决一些简单编程问题,对于提升学生的实践能力具有实际价值。
三、教学条件要求操作系统:Windows 10开发工具:IntelliJ IDEA四、课程的主要内容及基本要求第一章走进Java的世界第二章 Java编程基本功第三章面向对象编程第四章面向对象的特性第五章抽象类和接口第六章异常和常用类第七章集合框架第八章 I/O流第九章图形用户界面第十章线程与并发第十一章网络编程第十二章使用JDBC操作数据库第十三章幸运小猫爱心平台初心至善·匠心育人五、学时分配六、考核模式与成绩评定办法本课程为考试课程,期末考试采用百分制的闭卷考试模式。
Java编程入门,英语教材
The loop iterates The expression is evaluated again
The loop will continue to iterate until the expression evaluates to false
NOTES
When we run the above program only one shape will be processed – not 3 The shape processed will be determined by the user – by entering 1, 2 or 3 If the user enters something other than 1, 2 or 3 the program will give an error message
It checks a boolean conditional expression (true/false)
If the expression is true
The if path is followed
If the expression is false
The else path (if it exists) is followed
Be careful of infinite loops – usually a bad thing
CODE DEMONSTRATING WHILE LOOP
void whileTest (Scanner scan) { int i = 0; while (i < 5) { ifTest(scan); i++; } }
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C HAPTER38 A DVANCE
D J AVA D ATABASE
P ROGRAMMING
Objectives
■To create a universal SQL client for accessing local or remote database(§38.2).
■To execute SQL statements in a batch mode(§38.3).
■To process updatable and scrollable result sets(§38.4).
■To simplify Java database programming using RowSet(§38.5).
■To create a custom table model for RowSet(§38.5).
■To store and retrieve images in JDBC(§38.7).
IGURE38.1You can connect to any JDBC data source and execute SQL commands interactively.
ISTING38.1SQLClient.java
38.2The CopyFileToTable utility copies text files to database tables. Listing38.2gives the solution to the problem.
IGURE38.4The program enables you to navigate the table and delete rows.
The status bar at the bottom of the window shows the current row in the row set.The cur-in the row set and the row in the JTable are synchronized.You can move the cursor
using the navigation buttons or by selecting a row in the JTable.
program enables you to retrieve data,including images,
can use the buttons to display and modify a single record Course table is displayed in a JTable using ResultSetTableModel ResultSetTableModel
)Listing 38.8,RowSetTableModel.java,(a)(b)
IGURE 38.6The program demonstrates the performance improvements that result from batch updates.
The query result is displayed in a JTable.
Editing table using RowSet)Rewrite Listing38.10to add an Insert
insert a new row and an Update button to update the row.
Displaying images from database)Write a program that uses JTable
play the Country table created in Listing38.11,StoreAndRetrieveImage.java, as shown in Figure38.10.
Country table is displayed in a JTable instance.
and retrieving images using RowSet)Rewrite。