![]() |
|
applications Java
50 heures |
écran rafraichi le |
Plan du cours IPA2002:
Java Tutorials
Java Newsgroup comp.lang.java
Java Mailing List http://java.sun.com/mail.html
http://developer.java.sun.com
Bibliographie
Programmer en Java par Anne Tasso - Eyrolles initiation
Programmer en Java par Delannoy - Eyrolles
Core Java2 tome I et tome II par SUN
Thinking in Java by B.Eckel
autres livres sur amazon.fr +autres
Programmer en Java sous Linux avec emacs
Programmer en Java sous Windows en installant un éditeur :
JDK Java2 Developpement Kit from SUN http://javasun.com :
JBuilder environnement from www.borland.com
Class a Java prog. consists of a set of Class definitions |
method ( ) n'existe que dans une Classe |
variable to store values or expression in variable |
an instance of
a Class is an object Classe d'objets |
instance
method ( ) the prog. calls an instance method ( ) : <object>.<method name>(arg1, arg2 argN) |
instance
variable Java assigns default initial values = 0 , null, boolean false |
use the new operator to create a
new instance of a Class (Java runtime system allocates memory for that instance); then the
constructor for the current Class is called to initialize that memory public class MyClass <class constructor, methods, variables> } use super to explicitly call a constructor from the superclass of ths current Class use this to call a constructor already defined within the Class |
static Class
method ( ) the prog. calls a Class method ( ): <Class name>.<method name>(arg1, arg2 argN) |
static Class variable |
the default constructor doesnot have arguments | the main
method ( ) controls program's execution Must be declared in the top-level Class of the program: public static void main (String [] args) {} |
local
variable no default initial value; Java requires you initialize local variables before they are used ex: for (int i=0; i<9; i++); |
method ( ) modifier w/o scope affect | variable modifier | |
|
finalize ( ) is a method to clean up any outstanding resources |
|
Package & import statement |
affecting scope method
( ) modifier |
variable scope & variable extent in java |
From within a
package, all classes can access each other's friendly members. From outside a package, only public and protected classes, methods ans varaibles may be accessed import <package_name>.<Class_name>; |
|
the scope
of a variable, is the region of prog. from which the variable can accessed
|
arrays in
Java are objects array must be created with the new operator int[] scores; scores = new int[10]; |
||
overriding
methods ( ) |
variable type |
|
attributes and methods ( ) are inherited from the parent Class (superClass) | Java primitive
type char, int, float, double, boolean an instance of a particular Class
Cast operator |
Quick reference
equality operators | = = |
x,y: arithmetic types x,y: boolean x,y: object |
x equals y x and y both true or both false x and y refer to same object |
keywords |
|
abstract | a Class or method( ) modifier. An abstract class is used for classes that include abstract methods An abstract method( ) is used for methods that are generic and that will have their operations fully defined in sub-classes of the abstract class. |
interface class | its methods have their operations defined in the classes that implement the interface |
boolean | one of java's primitive types; by default, initialized to false |
break | standard control transfer statement. Passes control to the end of an enclosing iteration |
class | keyword to introduce a new type |
extends | keyword that specifies the superclass or superclasses of the sub-class or interface being declared |
implements | keyword that specifies the interface(s) that will be provided by the class being declared |
import | keyword that specifies packages or classes that can be used with a program |
final | a class, method( ), or variable modifier. A final class cannot be subclassed A final method( ) cannot be overridden A final variable cannot have its initialized value changed |
new | keyword used to create an instance of a class |
null | keyword indicating the absence of a reference |
private | a constructor, method( ) or
variable modifier. A private constructor, method ( ) or variable can be accessed only within the same Class |
protected | a constructor, method( ) or
variable modifier. A protected constructor, method( ) or variable can be accessed by other methods in the Class, methodsin subclasses of the Class, or methods in classes in the same package as the Class. Private protected members may be accessed by methods in the Class or methods in subclasses of the Class |
public | a class, constructor, method(
), or variable modifier. A public class, constructor, method( ), or variable can be directly accessed or imported from other packages |
return | standard control transfer statement. Passes control to the caller of the current method( ) |
static | a method( ) or variable
modifier. A static method( ) is used to declare a Class method( ) A static variable is used to declare a Class variable, which will be shared among all instances of a class |
switch | standard conditional control flow |
synchronized | a method( ) or block modifier. A synchronized method( ) or block acquires a lock on a resource, executes the specified code and releases the lock. Used for multithreading |
this | keyword used to reference the current Class or a constructor defined in the current Class |
throw | standard control transfer
statement. Indicates a runtime exception. By convention, the argument to throw is a subclass of the Exception class |
Exception | |
throws | a method( ) keyword that lists all the exceptions the method( ) can throw |
transient | |
try | keyword used in exception handling |
void | standard null return type |
volatile | a variable modifier indicating the variable may be asynchronously modified |
Fonctions rencontrées