.


:




:

































 

 

 

 


.




(exceptions) (runtime) , . , , , , .

- . , , , , . , . , . : .

. . , "" (throws) -. "" , , , (try) "" (catch) . , , , . (try) (catch) -, , , try{} catch {}. catchou , , . catch(){} .

. :

class SimpleExtlf

public static void main(String[] args){

try{

int n = Integer.parselnt(args[0]);

System.out.println("After parselnt());

System.out.println(" 10 / n = " + (10 / n));

Systfem. out. println ("After results output");

}catch(ArithmeticException ae){

System.out.println("From Arithm.Exc. catch: "+ae);

}catch(ArraylndexOutOfBoundsException arre){

System.out.println("From Array.Exc.catch: "+arre);

}finally{

System.out.println("From finally");

}

System.out.println("After all actions");

} }

try{} catchou . -, tostring() -. , finaliy(). , , . , , , , try{} return. finally{}, catch () {} , . . , - - . , .

 

30. , , , .

Java 4 :

1) , ( );

2) ;

3) ( )

4) - ( )

: 1. public class Parrot extends Bird

2. Wind left wind;

Wind right wind;

3. public Egg born (Parrot p, Nest n)

{

Egg a=new Egg(p,n);

return a; }

4. Parrot Kesha=new Porrot(true); Bird

Parrot Glasha=new Porrot(false);

Nest n=new Nest (30);

Egg child=Glasha.born(Kesha,n); ß

 

 





:


: 2016-10-06; !; : 509 |


:

:

.
==> ...

1824 - | 1632 -


© 2015-2024 lektsii.org - -

: 0.009 .