Anda di halaman 1dari 75

‫ﺗﻢ ﺗﺤﻤﻴﻞ اﻟﻤﻠﻒ ﻣﻦ ﻣﻮﻗﻊ‬

‫اﻟﺒﻮﺻﻠﺔ اﻟﺘﻘﻨﻴﺔ‬
‫‪www.boosla.com‬‬
palteam_ps@yahoo.com !" # $ %#
Java& ' ( )

Sun Microsystems
%& ' $ ! "# $
$( )"' ' Sun
." +)$ " , - "*)"Write once, Run Everywhere"
"Java 3 1' 2 + 0 / )"' & 0 -
$ 3 6 5 JVM ! 4 )Virtual Machine"
$ !+ 9 : ;& 0 7 ' !4 2 2 8
95 " 46 9 5 $ 8 + ' $ +' +
!+ 9 $ ) '0 8 + ' *) ) *) < "
@ *) $ " " ?=> Linux ( !+ 9 2 Windows
<8 + ' &
? ' & A$ !+ / 4 9 $ 5
35 7 Web - 9 & D+ 8 ' BC 9> '
FD+ % (Java Applets) ' @ +E' ' @ +5 9 5
- 7D! 3$ 9 "# 9 5 35 ' G /(
. B 0
+ + - $ C C ' 8 ' $ '
& + " 9 -' $ & H % I A
.? 2 ) $
J "4 ' !+ B $ +) !4 C
J B K4 C 0 +L 4 J @ +E' 7
B 0 9 "4 M N M) , & B#
< D $+ 8 ' E % & (Garbage Collector) D+

palteam_ps@yahoo.com !" # $ %#
/ D! / " " "' B '# )
" % -) ," O 4) / D! # ' N MG
Object/!
+ ," ' " C " ,C K( !4 ;& Sun 3 "
: + &)

JDK (Java Development Kit) 1

C 9 5 "! 8 + ' $ ' *& -javac.exe


.;& D+ D B *& (byte code)
C & D+ ' 7 *& 8 + ' *) ' $ -java.exe
&5 0 ," ' C & D+ B# 0'
JIT ) (Just-in-time) ' 8 95 C &
9 java.exe 8 + ' " ! D '; D 3)
D ' %& D ) $ > , & 95 C
.$ (
(Applets) ' & D+ ' 7 *& -applet Viewer
"4 8 ' 6 ( Documentation ) > " *& -javadoc.exe
< HTML D !'
JER (Java Runtime Environment) -2
( ! "# $% &%! '

palteam_ps@yahoo.com !" # $ %#
%
Object Oriented / " G ' ' " ' C P
"4 ' $&' *& " > Programming (OOP) :
" ' 8 ' " ' + " '
- B " $ )8 ' 9 8 + ' *" - 95 35
" Q, >), > ' ; 3 ' @ +R 8 + '
/" G ' ' ) << " 8 + ' @ +' ," +
F ) " + '9 * ! + @ +5 ," " , D'
!D , ' ," 8 + ' @ +' ," '!) ' << 8 + ' @ +5
. > !4 $ Object !+ )

JVM 8 + ' $ (' JVM : ! 4 & D+ ( ' P


+' ' M E ' : 8 + ' '
.$
9 " GS + Class Libraries : # $( ! ' P
$( !D $ ) # $( ! ' 9 * OOP D
' + ' " # D B $ $> $ T '
. + +R B $ %&
( +' F ) @ +5 "+ C,C++ : U 9 +' P
)"' )"' ' C,C++ O #) )
"" 35 > C++ 4: 9 + $' 4:
.

palteam_ps@yahoo.com !" # $ %#
! *+# )
“JVM” : ,# *
#, JAVA Virtual Machine , , ' ! 4 JVM /
<$ +) )B 9 $ $ ( +E'
8 ' $ 8 + ' +I Software ' @ +5 9 , D
8 ' D ' ,C G 9 S ) 2 C+5 $ + $ Runtime
$ +) C & C >$ + D
+) ' ! 4 JVM " " 5 " ' ," $ + > 9
) WINDOWS $ + - 8 + ' &5 = << $
JVM " C 9 C 95 $ >- 8 + ' ) UNIX ,
.8 + ' $ ' " +

Java Applet -2
" " E' W + +T S! !4 ! *& ' V +) V +
$ ' HTML / "4 $=4 2 " > Applet 8 + ' &
)HTML . U / 2 " server " 4 9 Applet 8 + '
52 + & HTML / $4 " ( " Applet @ +5
. " F " $=4 X @
: - # Java Application -3
+B $ O 4G ' B ' ,I + ' 2' 0'
+ +T 8 ' "W +) + +R ' S" ' $
@ 0' *) " " 5 , + > +) S3 ) M
CLIENTSERVER . ' ' K 4 ) DISKTOP '

palteam_ps@yahoo.com !" # $ %#
! , "
#+
O 4G G B ' ' , D *) F ) '
B +9 %& + $ #- ' "4 +
- 0 %& <8 + ' $
< $ D' ' 5

- ) = , ' ' !4'


<+ #

;& - "! + ++E & ' $ + "+ &5


<Y << $ & )

Z " # 3R ' =>


count++;

# 5 / 3 >count #- ' ;& '


<"

Z N' 3 '' => - 3 '

x*y*z

" 'y '- 3 > x #S )- - 2' +


' B 4) ' "' z ' + - 3 > '
< ' , 4G

palteam_ps@yahoo.com !" # $ %#
#+ . !

postfix operators [] . (params) expr++ expr--


unary operators ++expr --expr +expr -expr ~ !
creation or cast new (type)expr
multiplicative * / %
additive + -
shift << >> >>>
relational < > <= >= instanceof
equality == !=
bitwise AND &
bitwise exclusive ^
OR
bitwise inclusive |
OR
logical AND &&
logical OR ||
conditional ? :
= += -= *= /= %= &= ^= |= <<=
assignment >>= >>>=

palteam_ps@yahoo.com !" # $ %#
V + $ 8 + ' $ $=4 , ' "4
: $ " $
Format

&/ 0
8-bit two's complement
byte
!
Byte-
length
integer
Short integer
short 16-bit two's complement
" #$% & %' ()* # + , - . /0&1
2- 34
Integer
int 32-bit two's complement
34 " #$% & %' ()* # + , -
! 2-
Long integer
long 64-bit two's complement
34 " #$% & %' ()* # + , -
! 2-

"" + &/ 0
Single-precision floating point
float 32-bit IEEE 754
34 " #$% & %' ()* #$45 6 )7*
! 2-
Double-precision floating point
double 64-bit IEEE 754
34 " #$% & %' ()* #$45 6 )7*
! 2-

palteam_ps@yahoo.com !" # $ %#
1 2 3
A single character
char 16-bit Unicode character
8 % 948
A boolean value (true or false)
boolean true or false
;+ 4+< %' ;+ : !: # +)

Import java.io.*;
Public class Count {
Public static void countChars(Reader in)
throws IOException
{
int count = 0;

while (in.read() != -1)


count++;
System.out.println(“Counted “ + count + “
chars.”);
}
//..main method omitted..

palteam_ps@yahoo.com !" # $ %#
5 6
" # # ) B $ 95 L + G >
# + Array U' / %& - + V + + + '
2 ArrayV + + ! ++ V +) 9 +
B $ + )" +, > + ) # G B $ < !4
"4 + & ? ) + / ;& $> "#A /
Strings.V +
Arrays

D ' + ) )- ++I V +) 'B $


, ' Array ) ' < + ," D B +9 + + '
' + # G V +) / 4 "# # G ;& I # )
<?Y <<< !A

Z $> ++

int[] arrayOfInts;

int[] arrayOfInts = new int[10]

for (int j = 0; j < arrayOfInts.length; j ++)

arrayOfInts[j] = j;

System.out.println("[j] = " + arrayOfInts[j]);

palteam_ps@yahoo.com = !" # $ %#
<? ! # G V + ;+ A 2D '$ G +#

? = ;& A2 "" ' + # %& " '

<?lengthA0 + A 2 + "4 >

+ #2 !+ $ +D3) >

< 9 % ' ' +# 4)

%+ J 2+ ' ( J , ' Array V + Z =


$> + 2 " Rlength $> "4 B + @3 )
<2 , & @C C new G + "4 %& <0'

Strings
< # G $"' / G B $ 2+ 0' V + ' 2' V + &

B > 0 ? @ " 4A

String[] arrayOfStrings = new String[10];


for (int i = 0; i < arrayOfStrings.length; i ++)
{
arrayOfStrings[i] = new String("Hello " + i);

palteam_ps@yahoo.com !" # $ %#
;& A2 "" 2D '$ G +#
? =

?length< 0 + A 2 + "4 >

<+ #2 !+ $ +D3) >

!"
* ) * +, , - +*$ $ %& ' ($ #
4 2 3 & 0 - . / 0 1 0

7 3 # &'

Z $ " ) ++

9+ G

B+! if-else, switch-case

for, while, do-while

@ 4G try-catch-finally, throw

)
break, continue, label: , return
D 4

palteam_ps@yahoo.com !" # $ %#
!' = > ' < 3+ ; 83 #9 :

# &4 =4 B + G + " $3
* Y B3+ * X &5 $ + => 8 + '
<& =

=> + , " $4"+ =4 G + '


$" 'X # $" ' Y # $" "C = ! X
<3)

8 + ' @ 4 / + )B + G + Z; 0
<B# &5
+ , C %+ " I +) ;& 2 + + "' -
$ ' ' D4 , ;& > G , O G' )
N '' + $ + < G % ) $ $> O
<$ !D

palteam_ps@yahoo.com !" # $ %#
" $3

if - else @ ' ? 0

if ( ' )

Statement

else

Statement

) )Statement G' S !? ' A &5 +


*) + Statement <Statement G' ! '
< ' +) ', D

palteam_ps@yahoo.com !" # $ %#
/! ' ) ' % %+ N A $ >
! = -
>- $ = ' testscore "4 +
Z ?O ' grade "4 +

int testscore;
char grade;

if (testscore >= 90) {


grade = ‘A’;
} else if (testscore >= 80) {
grade = ‘B’;
} else if (testscore >= 70) {
grade = ‘C’;
} else if (testscore >= 60) {
grade = ‘D’;
} else {
grade = ‘F’;
}

palteam_ps@yahoo.com !" # $ %#
switch - case 0

+ )9 # '4 G & "4 +


<+ + '

" + + ' )N Z %& 9 $ > &4I+


' 9 9 * month ; +
+ - ) ' " + ++) > + )
* => &E month #9 @ +' 7 !
+ - )N D ' )/ +
)/ O + <+ B' $ ') )April
Z ' + >G G &

int month;
switch (month) {
case 1: System.out.println(“January”); break;
case 2: System.out.println(“February”); break;
case 3: System.out.println(“March”); break;
case 4: System.out.println(“April”); break;
case 5: System.out.println(“May”); break;
case 6: System.out.println(“June”); break;
case 7: System.out.println(“July”); break;
case 8: System.out.println(“August”); break;
case 9: System.out.println(“September”);
break;
case 10: System.out.println(“October”); break;
case 11: System.out.println(“November”);
break;
case 12: System.out.println(“December”);
break;
}

palteam_ps@yahoo.com !" # $ %#
'

for ? 0

for ( "' ; + ; $" )

statements

$" - 9 + "' ," C' '

Z $> &4I+

int i;

for (i = 0; i < 50; i++) {

...

// @ ' # +

...

) 9 5 [\ ' ' / ' ) O + $> &


< =* i # 7'!

palteam_ps@yahoo.com !" # $ %#
while & 0

while ( ' )

statement

< statement &D+ &5 7 ! ' "

Z $> ++

while (X != 10) {

X++;

System.out.println(“X does not equal to 10 yet “);

& + 0 do while

do {

statements

} while (booleanExpression);

<7 ! booleanExpression ' " statements $ +

palteam_ps@yahoo.com !" # $ %#
Z $> O +

int c;

...

do {

c-- ;

...

} while (c != -1);

6!

break A/ 0

G + "4 = %+I 9 G switch - case G 95 +

< - & 2 B' $> break /#

+ ' , D @C - & /# G O 4) D %+

palteam_ps@yahoo.com !" # $ %#
I' > Z +U' % & B' + > '
Z

breakToHere: someJavaStatement

) *I' > Z + ' ' breakToHere + = + 4 O +

Z = CD B + / 4 B# %& " ' @ +

break breakToHere;

"4 + goto G' 2' G & Z =

<

palteam_ps@yahoo.com = !" # $ %#
Inheritance 4
oop ! !4 ' ( 95 G N' L + "#.
9 #" 2 D! > ' + “class” /+! > '
+ "+ +
public ….
* 2 J $ ) ' 2> )B ” class ” /+! *) $ '
public
super class-G /+! ' 2 D! *& /+! * *& /+! +
subclass2 + 4) /+! *& /+!
" )- ) 8 + ' ' 8 ' >)% , ' 8 '
] 0 *) * " class *) abstract classes '
abstract classes subclass +!' 4: ' << $ '
)+ " " 2+ " ( abstract classes + method
D "4 + > )0 V 3 3) / + )-
subclass B3+ ) $'#extends

public class SUPER {


public int x;
public int y;
protected String name;
public void method()
{
…….
}
}//end super class
class SUBCLASS extends SUPER
{
public static void main( String [] arg) {
//can use any parmter or method by class supper
{
{//end subclass

palteam_ps@yahoo.com !" # $ %#
<$ G "" P > Zopp U D

? ' A," " / D! 0 4 ," 5 *)Z > 2 3 ' ( H D


O 4) ," " K( !4 " /! ," K( !4 FD+ ^ ?@ ')A "# / D!
< ' /! ' ! 4

superclass -G /! 9 0

subclass ' /! 9 0

<extends 0 >

-) ' /! $ + A$ G ,"" > %+ F " ) > >


<?" '

Z =

ZS )

sub object is a super object

Z*) 7 ! MF -G /! N M ' /! N M *) ) +

super object is not a sub object

public V + &5 -G @ 3 ) 9 5 $ ! 2+ ' /! Z_ + >

<private V + + &5 -G @ 3 G $ ! 2+ ' /!

&5 2 5 $ ! ' B package access V + -G @ 3 ) + &5 )


< package U FD+ 3 '

' /! -G /! $'# 5$ ! Z protected + &5 )


<-G /! C ," / D!

palteam_ps@yahoo.com !" # $ %#
Z_> >

/! $4 " -G /! ," M ! ," 5 *)Z over riding U D


< ' /! ' + M -G ! "# 2+) % & -' '

Z_ '

< /! -G /! 9 5 super $

Z_ 4

< > + Z is a U D

39 " /! N M "4 > /! @ " $> Z has a U D


< 2' + *& /!

Z_ "

U 0 %& ' /! N 9 5 -G /! N $
< exeptionZ *) @ +> +" 8+ casting U B3+ &5 ^ * casting

Z_ '

*) <super $ ' +' B3+ 9 + ' -G /! ' /!


3 +' @ " ' + ' $4 " super B3+ &5^ -G + ' &D+
&5 ? null^ + ' false^ ` D! ' ] *& A-`
-G A object /! 3 +' @ " ' ' -` 3 +' %+
<?

palteam_ps@yahoo.com !" # $ %#
Z final V + / D! 0 Pa

<? " G -) ) A _"') > final V + /! P

U $ final V + $ 2 &5 Z final V + /! P


< final ' _ Z static V + 0 P < ' /! 2 over riding

< final ' ' /! B $C+ =


_ !) Z private V + 0

< final V + 2 0 B E final V + /! &5 P

< 2 &' " ' $ ) C &4I call U Z B P


2+G % & 2 &' " 2+ _ "' B3 final V + @ " O "+
<

Zfinalizer Pa

/! ," A finalizer U @ " "+ super sub B $ +/


? finalizer @ " 2+E gc $ $'# , & $' object

< %+ F ,"" > +" inalizer *) B3+ &5

; ') finalizer U &4I )- 2+' E / D! " ) finalizer $ + 3 &5


Z ' B3+

?super.finalizerA

palteam_ps@yahoo.com !" # $ %#
Exceptions ; 34 9

' M B3 " "+ ;" N M Exceptions @ +>


% + '
' ' C4 ' Data Members % N &
+
). ' M B3 (

Throwing Exception; 34 9 C BA/ !


9 5) 2 &#A 2 )- argument ( +> / / N 5
.$ V + & B $ ! !4 2 ' % + '" @C
2+ $ + ? 'A ;@ +') " ) Exception /! N M *& " 5
2
catch it

" ) Exception (/! / D! + ?N MG A @ +> bF ) N D'


RuntimeException/! " ? 2( +')

.F 2+ 8 + 2+ +% + ' " %+ &5


.F V +) " " ' +) method % + ' %+ &5
): 4 0' %+ A 4%" 2+E
catch it*) method$ 3 @ +> Z$ G 4
try 'method $ " 32 % "
catch 3? ! $ A $

palteam_ps@yahoo.com !" # $ %#
"

try{@ +> /& 2+I' % " }


catch( " $! &5 ;& D+ * *& " \ ?@ +> ' - + N
@ +> }

try-catch) B3+ A @ +> - Z +> 4


@ +> ?/& A "# ;& I' 5 "
;& " *& /! O A9 )O 9 5 @ +> O B
)
i
"
int myMethod() thorows EOFException {…….}

myMethod() : " *& /!

"
public MyClass{
…..
try{ int x= myMethod() ; }
catch(Excrption e){ ….. }
…..
}

palteam_ps@yahoo.com !" # $ %#
RuntimeException ; 34 9
/ D! Exception) / D! + N M)A @ +> %+
Exception ./! ' *& RuntimeException /!
' 4 4 " ' Compiler % 7 @ +> ;&
. '
RuntimeException) /! N M" 9+ 'A @ +> ;&
N V + 2+ 8 + *& /! V + ' ' " + @ 4) -' '
. ) I 4 V + (= @ +>
4 "4 A ! $ " ' Catch it %+ %& B
< ?% & " ) 5A '

; 34 9 = D !4

> ( +> ) V + Z @ +> /!


D! 9 $> ' ArithmeticException :
.

=> a /! N M9 * #$ @ 5 ClassCastException :
.2( ' " 2( +') " a /! FD+ F " " /! 9 5...

2 + ' D! + N M C4 ArrayStoreException :
. D! 2' + - +

2 O = null ( 2 # N M $ $ NullPointerException :
data member .$ ;" + 5 ) +' ) method $ ; new )

+ B 2 + @= method 9 5 ' IllegalArgumentException :


. '

palteam_ps@yahoo.com !" # $ %#
, ' 2 2 A 2> " @ +> B $ Z$ G 4 95 " +
(2> " $

"

\try
? D 4 / D! V + A > ) ) @ +> "# " +
& D+ $ ++ Catch $ + H +' 2 &D+ @ +> *) " & &5
finally
cStatment1
cStatment2
cStatment3
cStatment4
[

"
catch(IOException e){
try 2+ / O *& @ +> 8 "
2( '6 " ) ) IOException ) + A ! ' "" V + @ +> 8
$ + > " C= @ R &4 + O
finally
$ + IOException V + try / & @ +> &5
. catch
' @ +> /& method $ ) /! 5 ) << catch % + E
throws
) 4 "4 ,"( (
$ ' V + @ +> 5 5 <<< + > 4 "4
. 2 RuntimeException

palteam_ps@yahoo.com !" # $ %#
C @ 4) 9 $! 2 ' 5
.% + '
}

"
catch(Exception e){}

"# catch # ' 2 "" *& V + F 2 &# O *& @ +> "#


!!dd $ V + >) @ +> > ) %+
! <<< @ 'R > ) @ +'G ' ' catch ) B3+ )
'G 'G
).% + ' C @ 4) 9 $! 5 > , - (
$ ' G -G /! Exception catch (Exception e){} '@ +
. @ +>
' + V +G $ C )B $ @ +> V + *) $'
. " "# @ +> =

"
} " G % *& " finally{

: =
.@ +> /&# 2+ 8 + Statment2; & D+ ) N D'
> ' catch $ K 95 $ + > H +' Statment1; & D+ $! E
= ) + & finally 95 $ + > (= @ +>
Statment3;
Statment4;
.8 + ' @C ) " + ;& 9 ; ' + - & D+ *

palteam_ps@yahoo.com !" # $ %#
. 3 " 4 finally Z =

$ try 3" $ & D+ * @ +> *) try 3" /& &5 Z =


. " ) finally & D+ $ + catch $ $
: +> 4 4+ 9
.2 +' + " 2+ , ' @ +> - + "#
catch(Exception $ + catch ( $ ' + +G B3+ ++5 % + "#
catch) $ *) 2 A @ +> 2+ 9 5 *"J ? #" , e)
. C @ 4) 9 5 *"J

' catch 2 " ' @ +> 2 B 9!#) ) + )


<I 4

+ ' &5 > ) ," D >), ' % "#


" ) )A Exception /! N ) ' + 2+ # @ +>
-' ' * catch 95 ; *& ?;@ +')
<<<< @ +>

/! K( !4 N ' + N & +C4 ;& ," D =


?Exception /! ' -G A @ +> $ 2> *& Throwable

String + 2 Throwable /! G +'

, ' & 95 C @ +> "


< @ +> = '' '

Z @ +> $ ( * Throwable /! + N MG

? ' + >" A + ' ' , '

palteam_ps@yahoo.com = !" # $ %#
" $ Record of execution Stack & D+ F" $
<<<< @ +>

@ +> " '' method$ > D $ &

?L 4 $ ) $4" 4) LIFO )"' - $ Z Stack F" A

?@ " $4 "' @ " "#A " " @ 'B F" &

@D#' ' @ +> " " # * / & D+ F" $ E '


" method $ $ 9 $! + 9 method$ ;& @ " >
<@ " " # ' ' @ +> = method$

"

public class class3\

public static void main(String[] args) { method1[c?A

"

class class1\

method1 () { method2[c?A

palteam_ps@yahoo.com !" # $ %#
"

class class2\

method2e \ ?A

@ +> -' * "

?Amethod1 @ " = $! ) 9 5 class3 main ,@ ' )"' ' $>

& D+ $ F" ; @ " $ ) & <<<<

@ " 2+ 3 " class1 ?Amethod1 " ' ' & class3 %


?Amethod2

<$ G 0 & @ " & D+ $

" class2 " ?Amethod2 " ' & class1 %


< @ +> " =>

@ +> = -' " # F"

4G LIFO - ? ;@ +') " )A Exception N 95 2 '$ >


Z$ `

"

@ +> " *& " # ZPackageName.class2.method2

palteam_ps@yahoo.com !" # $ %#
*& " # PackageName.class1.method1: method2
@ " 2

@ " 2 *& " # PackageName.class3.main : method1

Z Throwable /! ," methosd$ )

F= ' M @ +> /! O " Z ?AgetMessage


< @ +> = ! 4 /!

A L 4 9 & D+ F" ' Z ?AprintStackTrace


? console$

L 4 O ' "" + ' FD+ Z ?printStackTrace(PrintStream s


< & D+ F" $ 2 - + *&

method$ ;& @ " + 9 5 >G @ D # F" " Z ?AfillInStackTrace


9 + method$ ;& @ " # 7'! @ +> = * # )
< ' @ "

palteam_ps@yahoo.com !" # $ %#
Interfaces D
"" + " +) 3 O 4G V +G 2 "4 V +
0( 9 * ;& 0 (D +3 )- + !+
(D " ) !+ K( !4

"

[ <attributelist> ] [ accessmodifier ] [ Shadows ] _


Interface name [ ( Of typelist ) ]
[ Inherits interfacenames ]
[ [ modifiers ] Property membername ]
[ [ modifiers ] Function membername ]
[ [ modifiers ] Sub membername ]
[ [ modifiers ] Event membername ]
[ [ modifiers ] Interface membername ]#C3
[ [ modifiers ] Class membername ]
[ [ modifiers ] Structure membername ]
End Interface

Attributes D! 7 ! 0' ! O +
/ " ;& ) + Shadows ) Public $> $ ""
* (D O 4) > FD+' ,"
Y <<< K( !4 " /( (D 3 ( !+ FD+ 9
9 - "" *& " "' K( !4 /( ;& / "" +
;& 3 ," !+ " ) + 0 ( *)
D )- *) Module ) Namespace O 9 /
) ) ' f ++ @ 5 3 ! M
Default "4 ' 3 !4 "" O 4) 3 )
!+ 7 ! "+ Private ) Public $> $ ! "" "4
( 3 "4 "+ Shadows ) Overloads "4

palteam_ps@yahoo.com !" # $ %#
Public $ ! "" "4 ' (D ;& !+ = R
7 ! (D % O 9 ; %+ *& G 3
I/ ' " )"' ) $3D "+ 3

>G N' : O +

K( !4 N ' 9 * K4 G / + )

"

Interface IPerson

Property Name() As String

Property Birthdate() As Date

ReadOnly Property Age() As Integer

End Interface

' N' / ++ )

"

Interface ISomeMath

Function AddNumbers(ByVal a As Integer, ByVal b As Integer) As


Integer

Function AddNumbers(ByVal a As Double, ByVal b As Double) As


Double

palteam_ps@yahoo.com !" # $ %#
Function Multiply(ByVal a As Integer, ByVal b As
Integer) As Double

End Interface

K4 G / " / + )

"

Interface IPhonebook

Inherits IPerson

Property Phone() As String

Property Address() As String

Sub ShowInformations?A

End Interface

"4 + Phonebook 0 ) + " +/ ( +" + 5 :


$ /3 (' )O + (D % 7 ! "' Implements
," " (D 9 5 % !+ G

"

Public Class Phones

Implements IPhonebook

Public ReadOnly Property Age() As Integer Implements IPerson.Age

palteam_ps@yahoo.com !" # $ %#
Get

End Get

End Property

<<<<<<<

End Class

," (D 3 > ) "4

"

Class SomeTest

Implements IPerson

Implements ISomeMath

Public ReadOnly Property Age() As Integer Implements IPerson.Age

Get

End Get

End Property

<<<<<<<

Public Function AddNumbers(ByVal a As Double, ByVal b As


Double) As Doubleg

Implements ISomeMath.AddNumbers

palteam_ps@yahoo.com !" # $ %#
End Function

<<<<<<<

End Class

$ (D D B - + ' !+ % - + " ' % 9'


;& Public $ ! "" "4 ' 3 !+ B /

3 ' $4 "' f 9 $> &

"

Interface IPhonebook

Interface IPersone

Property Name() As String

Property Birthdate() As Date

ReadOnly Property Age() As Integer

End Interface

Property Phone() As String

Property Address() As String

Sub ShowInformations?A

Event SomeEvent(ByVal a As Int16?

End Interface

palteam_ps@yahoo.com !" # $ %#
(D 3 "4

"

Class test

Implements IPhonebook

Implements IPhonebook.IPersone

<<<<<<<

End Class

palteam_ps@yahoo.com !" # $ %#
Abstract E A3 0
9 $" * *) " B# * / +!G ; " /+!
e2 0 "] $D ) & 9+

" - " " = $ i h2 " ) 46 9+ '


) << 3 ' / ) , ' << " /+! ) (D & << ; M
" /+! % & /+! ' << '

implement =4 95 $ / D " $ 9+ '

' 9 2+ "e $ interface + +


4) ' /+! " /+! 0 + / << M + D "

3 ) methodUU $' ," ) ," / +!G , 9

abstract class PRINT


{
int X;
PRINT(int y){X=y;)
abstract void print();
}
class IMPPRINT extends PRINT
{
public void print()
{
System.out.println(super.X);
}
}
public class main
{
public static void main(String [] arg)
{
PRINT p=new PRINT()//error
IMPPRINT i=new IMPPRINT();
i.print();
}
}

palteam_ps@yahoo.com = !" # $ %#
/+! / $'# abstract D &' + # =
B' )
.." 2+ 9 "
/+! + ' B' " " B' )" /+! $4 " ) =+
" e G $4 " " *) B3 = )- *&
" *) + ) "' F # " D / 3 )method print U
" 9+ =' *& % & 0 ' # *& IMPPRINT /+! + ) >
.. ' ' #
" /+! object &4 ; )- ] main )
V 3 = N'
" M /+! $4 "' ," B' B3 -
9 0 B & D+ " /+! *& " /+! 9 - -
"4
," M B' 9 * " /+! 9 7 ! -
" M -G /+! 9 S" ' /+! 5 -
abstract class object +! 8 + *& I 4 V 3 + -

F
<< +@ FI - $ ) $ 4"R ' %+

$ 4"R % ) / $ 4"R " N'*


e $ ' ) $'<< 0 " +! $=4 $ 4"5 Joption V +

' DJ D! / J $ 4"T buffered #J * "


<8 ' - - 9 / )

Z - ' +) => $ 4"R 5 =+

?, $ " ' ,@ # 9 $ *& $ G - '+G A system inP

palteam_ps@yahoo.com !" # $ %#
)/ 95 ' $ $ 9 $ A InputStreamReaderP
?C

$ #J , & C )/ ;& B 9 $ A bufferedReaderP


? +

" 7'!

BufferedReader re=new BufferedReader


(InputStreamReader(System.inc??

object +I +) % & % & '2 2 +( ' +


@ $ ! ,@

class bufferreader U object re )

java IO ' " "+ :

"

import java.ioca<

class BRRead\

public static void main(String args[])throws IOException\

char cc

BufferedReader br = new BufferedReader(new

InputStreamReader(System.inc??

palteam_ps@yahoo.com !" # $ %#
System.out.println(”Enter charactersc?h

c = (char) br.readc?A

System.out.println(cc?

$ / ' +" ' $4"+ ) " + "+ " ' $ 4"5 0' "
char +

) +# / 95 ) $ >" $ )
/ $=4 " ' ,@

Z"

import java.ioca<

class BRRead\

public static void main(String args[])throws IOException\

String cc

BufferedReader br = new BufferedReader(new

InputStreamReader(System.inc??

System.out.println(”Enter charactersc?h

c = br.readLinec?A

System.out.println(cc?

palteam_ps@yahoo.com !" # $ %#
,@ # 9 $ " % & read $"' readLine B' "4 =+
enter / +' 3 "# C B / ,"

< string + $ ) =+

' D + ' $ 4"5 3) $ +/ $ 4"T '


bufferedU

<< 8 ' $ 4"R "4 3)

class scanner ' $ 4"T " O G ' ) O 4) 0 & /

$> 5 $ 4"R 2 "4 + 2+ object +!' + 3)

"

import java.util.Scannerc

class IN

public void in?A

Scanner sc=new Scanner(System.inc?

System.out.println(”enter Host or IPc?i

String Hots = sc.nextLinec?A

palteam_ps@yahoo.com !" # $ %#
scanner K 4 class$ "4 $ 4"5 ;& 3 )

G 9
public H ' +/ "'

,C + "+ public *: ) !+ class $ )2" + + *) J ,C


8 + ' ," 3 "+ => method ,C public
*) @ " ,C 8 + '

public class anyname


{
public void namemethod()
{
}
public static void main(String [] args)
{
anyname object=anyname();
object.namemothed();
}
}

8 + ' method @ " + = +

+" =>

public class anyname


{
public int X;
public int Y;
public void namemethod()
{
// > B X,Y +
}
public static void main(String [] args)
{
anyname object=anyname();
object.namemothed();

palteam_ps@yahoo.com !" # $ %#
}
}

* ? ("' A " ( " B + &5


…8 + '

> ) ! !4 2 public 0' $ F private J $ &5 )


..!!2+ object @ +5 B private class $' 9 9

protected 9 5 ) I+
> ' K 4 2+ public UU ' 2 ' J &
& extends 0 "+ class protected $ / ' + "+ =>
protected + &5 3 ) > 0 )B F=

public class anyname


{
protected int X;
protected int Y;
}
public class anyname2 extends anyname
{
// "4 B + X,Y
{

palteam_ps@yahoo.com !" # $ %#
"#

JBULDER 7 3 #

- M) $'# " 8 + ' & 8 ' 0' ' 8 + '


8 ' / 4 L +5 2 $ 'C '
< '

palteam_ps@yahoo.com !" # $ %#
palteam_ps@yahoo.com !" # $ %#
-+!,

palteam_ps@yahoo.com !" # $ %#
)
V @ +5 % 8 + ' 9 $ @"' PZ 9 G , ! <
% ?new project A " " V @ +5 "+ ' 73
< +> , ! 3
) C4 V + 4+ PZ + > , ! <
< 3 3 ' +
) 2 " " 5 "" + V =4 "" + PZ > > , ! <
< 2+ C4 B3
2+ V "" R + PZ ' , ! <
6 ; + 4") *& V + + @ +5 3+
< 3

0' $ @"' 8 + ' F= @ +E' ' + ' 4 "'


PZ ! ' 73 2

palteam_ps@yahoo.com = !" # $ %#
( +E' + 8 ' 0' 8 + ' 9 $ +)"' "# + &

palteam_ps@yahoo.com !" # $ %#
HELLOW 9 B' 8 + ' => 2 ' 8 + '$ 9 $>
PZ ! ' 73 WORD

palteam_ps@yahoo.com !" # $ %#
palteam_ps@yahoo.com !" # $ %#
PZ B' + 9 8 + ' ' "'

palteam_ps@yahoo.com !" # $ %#
JCreator 7 3 #

H 3

palteam_ps@yahoo.com !" # $ %#
2

palteam_ps@yahoo.com !" # $ %#
4

palteam_ps@yahoo.com !" # $ %#
6

palteam_ps@yahoo.com !" # $ %#
8

- 7 9 8 + ' ! 4 @ +5 =+ $ "'

8 + ' 7D G F C' 3
ZV ' @"' 7
1

palteam_ps@yahoo.com !" # $ %#
2

palteam_ps@yahoo.com = !" # $ %#
4
{V @"' $'# 2 D 8 + ' + ) "' }

8 + ' & D+ .

: B' + 8 + ' & D+ ," :


(# [Build ] 4+ [Execute project ]
3+ !4' )
[f5]

palteam_ps@yahoo.com !" # $ %#
TextPad 7 3 #

Next DEF G 14H I+, 0! # / I+840 #J J

palteam_ps@yahoo.com !" # $ %#
Next DEF K L+" #M3 I $ N+O40 #+) P

Next 3 @ *) ) $ ' "4 + ' $4)

palteam_ps@yahoo.com !" # $ %#
$=4 " ) 52 8 + ' - !+ " *& - )
Next 9' 3 )change

8 + ' - !+ ' @"' Install C 9 3

palteam_ps@yahoo.com !" # $ %#
Finish

PZ $ 9 % 3 2 ' #- 7 9 8 + ' + 5

palteam_ps@yahoo.com !" # $ %#
j2sedk 7 3 #

: ' # j2se sdk Y + 4 + *) $ ' "+


: ' # - !+ $ )
d$ = " I +) ' + 'd$ )c$ " " = " ] +) "'
:

9 3 $ "' " ' j2sdk 9 8 + ' - !+ ' # % & " '


: , ! change

palteam_ps@yahoo.com !" # $ %#
: , ! " ' # %& " '

: , ! next 9 3 %& " '

: , ! install 9 3 %& " '

command )- >$ > )"' 9 5 - &) 8 + ' & D+ % & " '
: , ! F " 95 $ !

palteam_ps@yahoo.com !" # $ %#
' + 'd$ )c$ @ 2 " $ " 95 $ + %& " ' >
: d #
? c: K C4 ," ' A dZ- )
cd java- )
cd bin- )
: , !

%& 8 + ' C4 , 4 & D+ B : $ ' 4 ;& ' # &5


' d:\java\bin $ " first. java 9 8 + ' D 0
: $ " C4 8 + '
d:\java\bin\first.java

palteam_ps@yahoo.com !" # $ %#
Java & #7 #
Z 3) ' $ ' " " " C $" ' + " " I' (# L 4 8 + '

import javax.swing.*;
import java.util.ArrayList;

public class while6 {

public static void main (String args []) {

int i = 1;
int c90 = 0, c80 = 0, c70 = 0, c60 = 0, failed = 0;
ArrayList<Integer> listC90 = new ArrayList<Integer>();
ArrayList<Integer> listC80 = new ArrayList<Integer>();
ArrayList<Integer> listC70 = new ArrayList<Integer>();
ArrayList<Integer> listC60 = new ArrayList<Integer>();
ArrayList<Integer> listFailed = new ArrayList<Integer>);

while(i != 0 ) {
String s = JOptionPane.showInputDialog("Enter number");
int x = Integer.parseInt(s);
if (x == 0)
i = 0;
if ( x >= 90 && x <= 100) {
listC90.add(x);
c90++;
} else if ( x >= 80 && x < 90) {
listC80.add(x);
c80 ++;
} else if ( x >= 70 && x < 80) {
listC70.add(x);
c70 ++;
} else if ( x >= 60 && x < 70) {
listC60.add(x);
c60 ++;
} else if ( x < 60) {
listFailed.add(x);
failed ++;
}
}
System.out.println("A "+ c90 + " - " + listC90);
System.out.println("B "+c80 + " - " + listC80);
System.out.println("C "+c70 + " - " + listC60);
System.out.println("D "+c60 + " - " + listC80);
System.out.println("F "+failed + " - " + listFailed);
}
}

palteam_ps@yahoo.com !" # $ %#
D3 # +/ &/ 0 2 # 2 H / ?

import javax.swing.JOptionPane;

public class sum_count_avg


{
public static void main(String args[])
{
int num1=0,num2=0,sum=0,coun=0;
float avg=0;
String message1=JOptionPane.showInputDialog("enter your first num:");
num1=Integer.parseInt(message1);

String message2=JOptionPane.showInputDialog("enter your second num:");


num2=Integer.parseInt(message2);
for(int i=num1+1;i<num2;i++)
{

sum=sum+i;
coun+=1;

}
avg=sum/coun;
String msg=String.format("the sum is:%d",sum);
String msg2=String.format("the Count is:%d",coun);
String msg3=String.format("the Average is:%f",avg);
JOptionPane.showMessageDialog(null,msg);
JOptionPane.showMessageDialog(null,msg2);
JOptionPane.showMessageDialog(null,msg3);
System.exit(0);
}
}

palteam_ps@yahoo.com = !" # $ %#
' - 7 ! "" $ 4"R ' 8 + ' - P)
PZ $4" "" $ ', ! " D # G B

import javax.swing.*;
class PrintOdd{
public static void main(String[] args){
String s = JOptionPane.showInputDialog("enter a positive integer");
int n = Integer.parseInt(s);
for(int i=0; i<=n; i++)
if(i%2 == 1)
System.out.println(i);
}}

<"" !) B ! "" G D! = ' - P-

public int min(int [] arr){


int m = arr[0];
for(int i =1; i< arr.length;i++)
if(m < arr[i])
m = arr[i];
return m;
}

- Person /+! / P)
?nameA ) ?idA # K4 $ •
G # ("' #"" ; 3# / •
K4 7 setName / •
class Person{
private int id;
private String name;
public Person(int id1, String
name1){
id = id1;
name = name1;
}
public void setName(String n){
name = n;
}
}

palteam_ps@yahoo.com !" # $ %#
W%45 I&8 Person S , T4$ UV % Employee S , 94 RQ
B#+ 0
\name[ ]' % \id[ #$ X )7 SY (Z •
salary IP 7 %
#$ L )4 #+^ 0! +) $ 0 . / 94 •
IP 4 % ]* %
;+0P >0 % getSalary #M$4_ 94 •
salary 4+E0 " ?

class Employee extends Person{


private double salary;
public Employee(int id1, String n, double s){
super(id1,n);
salary = s;
}
public double getSalary(){
return salary;
}
}

@ " D "4 xy B y x ' ! "" -


Z &

public int power(int x, int y){


if (y==0)
return 1;
if(y==1)
return x;
return x*power(x,y-1);
}

palteam_ps@yahoo.com !" # $ %#
olleH)B' Hello $ > A - '2 ' K+ $ 4"R '8 + '- )

import javax.swing.*;
class PrintInverse{
public static void main(String[] args){
String s = JOptionPane.showInputDialog("enter a sentence");
for(int i=s.length()-1; i>=0; i--)
System.out.print(s.charAt(i));
}}

palteam_ps@yahoo.com !" # $ %#
!

< D F" ? A? A '- •


< '+ ' 9 ' •
<- ' "+ •
<* B# •
< SUN JAVA B# •

" # $ % !
$ &

palteam_ps@yahoo.com !" # $ %#

Anda mungkin juga menyukai