类的构成包括成员变量/对象与成员方法,这样将相关的数据与函数包装在一起,同其他的类相区分,就是封装。显然,避免了面向过程语言的平行缺陷,说明了类和成员之间的所属关系。进一步地,可以限制类的成员在外部的可见性,那么就将封装体现得更完美。
2、继承
当一种事物甲完全是另一种事物乙的特例,那么,一般地,类甲只是比类乙多出一些成员变量/对象与成员方法,称为类甲继承类乙,类甲称为(类乙的)子类,类乙称为(类甲的)父类。
父类也称为基类、超类,子类也称为导出类、派生类。
显然编写子类就没有必要重复书写父类中乙有的代码部分,这是OOP中最典型的代码重用。
3、多态
多态表示一个类的某种行为存在多种实现版本。简单的情况是在一个类中,给出多种不同的实现,复杂的情况是在多个子类中各自给出不同的实现。
*1.5 Java与C++的差异 1.6本章小结 习题
1.解释Java语言的三种平台。
2.解释支撑Java语言目标的三种主要技术(自查资料完善)。
3.关于面向对象与面向过程的不同,从问题理解和问题表示两种角度,按照个人的理解和认识,例示其不同的地方
Overview of Java language
Java, from Sun Microsystems, launched in May 1995 of the Java programming language and Java in general. Hot Java implementation with Java browser (supporting Java applet) shows the charm of Java: cross-platform, dynamic Web, Internet computing. Since then, Java is widely accepted and promoted the rapid development of Web, popular browsers now support Java applet. Platform
Java platform by the Java Virtual Machine (Java Virtual Machine) and Java application programming interfaces (Application Programming Interface, referred to as API) composition. Java application programming interface for Java applications independent of the operating system of a standard interface, can be divided into the basic part and extension. In the hardware or operating system platform, after installing a Java platform, Java applications can run. Embedded Java platform now has almost all the operating systems. This Java program can only compile it once, you can run a variety of systems. Java application programming interface has been developed from a 1.1x version to version 1.2. The Java platform is based on the commonly used Java1.5, a recent version Java1.7.
Java is divided into three systems JavaSE (Java2 Platform Standard Edition, java platform standard edition), JavaEE (Java 2 Platform, Enterprise Edition, java platform enterprise edition), JavaME (Java 2 Platform Micro Edition, java platform, Micro Edition). Java SE JAVA
* Java SE (Java Platform, Standard Edition). Java SE formerly known as J2SE. It allows development and deployment on the desktop, server, embedded and real-time environment using the Java environment applications. Java SE includes support for Java Web services development classes, and for the Java Platform, Enterprise Edition (Java EE) to provide a basis. Java EE
* Java EE (Java Platform, Enterprise Edition). This version formerly known as J2EE. Enterprise Edition to help develop and deploy portable, robust, scalable and secure server-side Java applications. Java SE Java EE is built on the foundation, which provides Web services, component model, management and communication API, can be used to achieve enterprise class service-oriented architecture (service-oriented architecture, SOA) and Web 2.0 applications program. Java ME
* Java ME (Java Platform, Micro Edition). This version formerly known as J2ME. Java ME devices in mobile and embedded devices (such as mobile phones, PDA, TV set-top boxes and printers) applications running on a robust and flexible environment. Java ME includes flexible user interfaces, robust security model, and many built-in network protocols and networking that can be dynamically downloaded the rich and offline application support. Specification based on Java ME applications are written once, can be used in many devices, and can use each device's native capabilities. Origin of name
The birth of Java since 1995, it has been 16 years. The name of the source Java: Java is the English name of the Indonesian island of Java, known for rich coffee. Many libraries in
the Java language class name, more and more coffee, such as JavaBeans (coffee beans), NetBeans (Web Beans) and ObjectBeans (Object bean) and so on. SUN and JAVA identity is what is steaming cup of coffee.
According to James Gosling memories, TV set-top box was originally designed this as the language has been called the Green in Sun internal project. Our new language needs a name. Gosling noted that his thick oak tree outside the office of Oak, which is a very common tree in the Silicon Valley. So he named this new language Oak. But the Oak is another registered company name. The name can not be used again.
Call the meeting in the name, we made a lot of names. Final selection by our order of a dozen names will be arranged in the table, reported to the Attorney. Ranked first in the Silk (silk). Although we like the name, but was firmly opposed to James Gosling. Came in second and third did not pass the hurdle of lawyers. Only the name in fourth place, got all the recognition and adoption lawyers, the name is Java.
10 years, Java as Java, as world famous coffee, as deserved the dominant platform for enterprise applications. The Java language is like a coffee generally mellow and moving. Early Java
Java platform and language is just the beginning of 12 in 1990, Sun Microsystems began to study an internal project. Sun Microsystems, a named Patrick Norton ? Sun engineers are developing their own C and C compiler whipped, because the API is extremely difficult to use. Patrick decided to switch to NeXT, he also received a company called \
\n Patrick has also joined the working group. They and several other engineers in California, Sand Hill Road Menlo Park City studio inside a small research and development of new technologies, aimed at the next generation of intelligent home appliances (eg microwave ovens) programming, Sun Microsystems is expected that future technology will be appliances areas of their talents. Team initially considered using the C language, but many members include Sun Microsystems chief scientist Bill Joy ? and found that C and the available API in some respects there is a big problem.
Working groups are embedded type of platform, can be extremely limited resources. Many members find that C is too complex as well as many developers often used incorrectly. They found that the lack of garbage collection system C, as well as the safety of portable, distributed programming, and multi-threading capabilities. Finally, they want an easy migration to a variety of device platforms.
According to available funds, Bill Joy decided to develop a set of ? C language Great language and new language Mesa, in a report, Joey called it \Sun's engineers should be C, Based on the development of an object-oriented environment. Initially, Gosling attempt to modify and extend the function of C, he said the new language is C -, but later he gave up. He will have to create a new language, which he named \
Like many of the secret development of new technology projects, the Working Group to work day and night to the summer of 1992, they are able to demonstrate a part of the new platform, including the Green Operating System, Oak programming language, libraries, and its hardware. First attempt is a class for PDA devices, named Star7, this device has
bright graphical interface and is known as \intelligent agents to help users. December 3, 1992, this equipment was displayed.
In the same year in November, Green plans to be transformed into \Limited\Palo Alto. FirstPerson team building interest in a highly interactive devices, when Time Warner issued a request for proposals on the TV set-top box book (Request for proposal), FirstPerson changed their goal to seek submissions as a response to proposed proposed a set-top box platform. But the cable industry that FirstPerson platform to give users too much control, so lost to the FirstPerson tender SGI. 3DO Company and the other a transaction on the set-top box does not succeed, because of their platform can not produce any benefit in the television industry, the company picked up again and yang company.
The first JAVA program HelloWorld / / File Name HelloWorld.java
/ / Declare a class public class HelloWorld { / / Declare a method
public static void main (String args []) {/ / import procedures / / Output
System.out.println (\ } }
/ / Example package Text; public class Test {
public static void main (String args []) { short d = 12; / / short-integer
System.out.println (d); / / output d
long c = 144L; / / long integer, and to raise l System.out.println (c); / / output c int z = 15; / / integer
System.out.println (z); / / output z char e = 'I'; / / character \
System.out.println (e); / / output e } }
/ / No compiler tool to compile and run java program / / Path is relative path Compile java
javac [java source name. java] / / must be coupled with extension
/ / This time you will find more than your original one next to the program. Class files, file names and source files with the same name / / A compile error will be prompted to Run java
java [java source name] / / do not need to add extensions, automatic operation. class files
/ / Display program running results JAVA hit the Internet
JAVA applications
6,7 and July 1994, after a three-day brainstorming discussion, John ? Cover Kyrgyzstan ? James Gosling, Bill Joy ? Patrick ? Norton, and Eric Wayne ? Ross for g ? Si Kumi, the team decided to change the goal again, this time they decided to apply the technology to the World Wide Web. They believe that with the arrival of Mosaic browser, the Internet is highly interactive to the same vision of evolution, and this vision of what they see in the cable television network. As a prototype, Patrick ? Norton wrote a small web browser, WebRunner, later renamed HotJava. In the same year, Oak was renamed Java. Trademark search shows, Oak has been registered, a graphics card manufacturer, so the team found a new name. The name is frequented by many members of the local coffee shop in the coined. Acronym name is not yet clear, largely for not. Although the developer claims that the name is a combination of: James Gosling (James ? Gosling) Arthur Van Hoff (Arthur ? Where ? Hoff) Andy Bechtolsheim (Andy ? 贝克托克姆), or \Another Vague Acronym\argument is that the name is based on a love of coffee, so named for the coffee to Java. Class file if the first four bytes of hex read the words, namely CA FE BA BE, it will spell the two words \
October 1994, HotJava and the Java platform for executives to demonstrate. In 1994, Java 1.0a version already available for download, but the Java and the HotJava browser was the first public release in March 23, 1995 SunWorld conducted on the General Assembly. The scientific guidance of Sun Microsystems Kyrgyzstan declared John ? cover Java technology. This publication is Netscape's executive vice president and Mark ? Anderson, conducted with the amazing release, announced in its Netscape browser includes Java support. January 1996, Sun's Java business group set up specifically developed to Java technology. Review contributions
April 20, 2009, oracle (Oracle) announced the acquisition of sun.
In 1991, Sun's James Gosling. Bill Joe, who, for TV, control household appliances such as toasters interaction developed a Oak (the name of an oak) software, he is the predecessor of Java. At that time, Oak did not attract attention until 1994, with the rapid development of Internet and 3W, they used the preparation of the HotJava browser, Java, by Sun CEO Scott McNealy has the support to research and development. In order to promote and legal reasons, was renamed in 1995, Oak Java. Named after the section of Java, there is little episode does, one day, Java team members are drinking coffee, talk about what the new language from the name, it was proposed to Java (Java is an island of Indonesia is rich in coffee), this proposal was the approval of other members, so to use Java to name this new language. Java is quickly recognized by the industrial sector, many large companies such as IBM Microsoft.DEC Java purchased the right to use by the U.S. magazine PC Magazine named the top ten outstanding technology products in 1995. From then on, began a new chapter in Java applications.