background preloader

Java - Cours de Tim

Facebook Twitter

Javanotes 7.0. Javanotes 7.0 Table of Contents. Javanotes 7.0 Preface. Introduction to Programming Using Java Version 7.0, August 2014 Introduction to Programming Using Java is a free introductory computer programming textbook that uses Java as the language of instruction.

Javanotes 7.0 Preface

It is suitable for use in an introductory programming course and for people who are trying to learn programming on their own. There are no prerequisites beyond a general familiarity with the ideas of computers and programs. Overview: The Mental Landscape. Chapter 1 When you begin a journey, it's a good idea to have a mental map of the terrain you'll be passing through.

Overview: The Mental Landscape

The same is true for an intellectual journey, such as learning to write computer programs. The Fetch and Execute Cycle: Machine Language. Section 1.1 A computer is a complex system consisting of many different components.

The Fetch and Execute Cycle: Machine Language

But at the heart -- or the brain, if you want -- of the computer is a single component that does the actual computing. This is the Central Processing Unit, or CPU. Asynchronous Events: Polling Loops and Interrupts. Section 1.2 The CPU spends almost all of its time fetching instructions from memory and executing them.

Asynchronous Events: Polling Loops and Interrupts

However, the CPU and main memory are only two out of many components in a real computer system. The Java Virtual Machine. Section 1.3 Machine language consists of very simple instructions that can be executed directly by the CPU of a computer.

The Java Virtual Machine

Almost all programs, though, are written in high-level programming languages such as Java, Fortran, or C++. A program written in a high-level language cannot be run directly on any computer. First, it has to be translated into machine language. This translation can be done by a program called a compiler. Fundamental Building Blocks of Programs.

Section 1.4 There are two basic aspects of programming: data and instructions.

Fundamental Building Blocks of Programs

To work with data, you need to understand variables and types; to work with instructions, you need to understand control structures and subroutines. You'll spend a large part of the course becoming familiar with these concepts. A variable is just a memory location (or several consecutive locations treated as a unit) that has been given a name so that it can be easily referred to and used in a program. Objects and Object-oriented Programming. Section 1.5 Programs must be designed.

Objects and Object-oriented Programming

No one can just sit down at the computer and compose a program of any complexity. The discipline called software engineering is concerned with the construction of correct, working, well-written programs. The Modern User Interface. Section 1.6 When computers were first introduced, ordinary people -- including most programmers -- couldn't get near them.

The Modern User Interface

They were locked up in rooms with white-coated attendants who would take your programs and data, feed them to the computer, and return the computer's response some time later. When timesharing -- where the computer switches its attention rapidly from one person to another -- was invented in the 1960s, it became possible for several people to interact directly with the computer at the same time. On a timesharing system, users sit at "terminals" where they type commands to the computer, and the computer types back its response. Javanotes 7.0, Section 1.7. Section 1.7 Computers can be connected together on networks.

Javanotes 7.0, Section 1.7

A computer on a network can communicate with other computers on the same network by exchanging data and files or by sending and receiving messages. <== Parties faites Parties à faire ==> Javanotes 7.0, Quiz on Chapter 1. Programming in the Small I: Names and Things. Chapter 2 On a basic level (the level of machine language), a computer can perform only very simple operations.

Programming in the Small I: Names and Things

A computer performs complex tasks by stringing together large numbers of such operations. Such tasks must be "scripted" in complete and perfect detail by programs. Creating complex programs will never be really easy, but the difficulty can be handled to some extent by giving the program a clear overall structure. The Basic Java Application. Section 2.1 A program is a sequence of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form that the computer can use. This means that programs have to be written in programming languages. Programming languages differ from ordinary human languages in being completely unambiguous and very strict about what is and is not allowed in a program. The rules that determine what is allowed are called the syntax of the language.

Variables and the Primitive Types. Section 2.2 Names are fundamental to programming. In programs, names are used to refer to many different sorts of things. In order to use those things, a programmer must understand the rules for giving names to them and the rules for using the names to work with them. <== Parties faites Parties à faire ==> Strings, Classes, Objects, and Subroutines. Section 2.3 The previous section introduced the eight primitive data types and the type String. There is a fundamental difference between the primitive types and String: Values of type String are objects. Javanotes 7.0, Section 2.4. Section 2.4 We have seen that it is very easy to display text to the user with the functions System.out.print and System.out.println. But there is more to say on the topic of outputting text. Furthermore, most programs use data that is input to the program at run time, so you need to know how to do input as well as output.

This section explains how to get data from the user, and it covers output in more detail than we have seen so far. It also has a section on using files for input and output. Javanotes 7.0, Section 2.5. Section 2.5 This section takes a closer look at expressions. Recall that an expression is a piece of program code that represents or computes a value. An expression can be a literal, a variable, a function call, or several of these things combined with operators such as + and >. The value of an expression can be assigned to a variable, used as a parameter in a subroutine call, or combined with other values into a more complicated expression.

Programming Environments. Javanotes 7.0, Exercises for Chapter 2. Javanotes 7.0, Quiz on Chapter 2. <== Parties faites Parties à faire ==> Programming in the Small II: Control. Blocks, Loops, and Branches. Javanotes 7.0, Section 3.2. The while and do..while Statements. Javanotes 7.0, Section 3.4. Javanotes 7.0, Section 3.5. Javanotes 7.0, Section 3.6.

Introduction to Exceptions and try..catch. Javanotes 7.0, Section 3.8. Introduction to GUI Programming. Javanotes 7.0, Exercises for Chapter 3. Javanotes 7.0, Quiz on Chapter 3. Programming in the Large I: Subroutines. Programming in the Large II: Objects and Classes. Introduction to GUI Programming. Javanotes 7.0, Chapter 7. Javanotes 7.0, Section 7.1. Correctness, Robustness, Efficiency. Linked Data Structures and Recursion. Generic Programming and Collection Classes. Advanced Input/Output: Streams, Files, and Networking. Threads and Multiprocessing. Advanced GUI Programming. Javanotes Source Code. Javanotes Glossary. Javanotes Version 7. Les meilleurs cours et tutoriels pour apprendre JAVA. Ref 01 : Tutoriel pour bien débuter en Java.

Penser en Java 2nde édition.