You are on page 1of 27

c  c    

Y       
                  

   


              

               


       

 
  

Y            
           


   
                  

        
!                 
" 

 
!  
 
          
       

 


          


     #

           






$
"   
  
     
       Y   
  

      
     
           

 


    
 
 
 
  
  Y           

#

             
   


   "
   
      Y  

      ! 


 
    Y         


     
"       Y   
        

        


"  %     
Y        
 
      "
   


!

     
     " 
 .class 


 


       


  
"          Y   &
   

'Y&(  
 

  




Y&              


   
      

   
   Y       !          

        


 
 $      Y   
   

 
  )    *     !     Y    
       


   
"     !     Y&  

+    
 
 
   Y   
 Y   * 
 +
 'Y*+(

         


  Y*+  
   
   


    #
 
 
  Y    
Y  , 
 
Y  

&
  #
 
Y  !
   !
Y  , 
 - 
'Y,-(


       
     .
       Y   
 

Y*+!  
           
 Y        Y,-    / 


   
 '  
 Y     (      
     

 Y,-   Y  0 


   Y&

º 
      
 
!    Y              

 
         
    
1   

   
 "!  
" !
 "!  !  !
 !  0 

ÑÑ

Y            
  $   
    

     
 
       
       

      / Y  


    
   " 


    


 
  
   



   
           ! Y         


               0    
      

 
     
  %            


    Y                    


0


     *        
   Y  !    " 
   Y  

  
      
   
  
  
 
 


      0 





   

.
  
  Y  ! 

 
   !    
  Y*+

$ 
  Y*+

  
    
   
  





/  
                     
 

     .                   


  
 Y*+
 


  
      
Y*+    ° .4

    2 3            


 SET PATH=° .4

  " autoexec.at   .


 2 /4566647$         


 ° .4     ath
 - 
   8  

My Computer!   Properties +    


 Advanced 1   
  Environment

Variables!    ath!  


  

Y*+     


 .
 1 9!
     
 SET °
ASSPATH=4   
 

" "   .


   Y*+! 
  
 ava   avac     


'
 *:   $
( Y  


          ava


avac      


    .
         " 


    
     #

 * 
 - 
 '#*-( 
   

Y   
   

   

.
   0             
  
     Y  

     8

|  
        

  #
! "

  


.ava  


5|     


 avac  8 avac HelloWorl.ava

Y  !     "


   .class

;|   


  
 ava$  
  
      

"   tanpa


.class
 8ava HelloWorl



 
HelloWorl.ava8

ulcclass HelloWorl

ulc statc vo ma Str  ar s)

System.out. rtl A a Kaar Dua?);

*     


   !  
 
    
   
  



 " HelloWorlA let.ava8

m ort ava.awt.Gra hcs;

ulc class HelloWorlA let extes ava.a let.A let

ulc vo at Gra hcs )

.rawStr A a Kaar Dua? 5 25);

      
  
     
 
      
  !  

    
 +        

 


           





$  
       Y   "
   
!       

 
      "        
        

     
  



!                 

 

  
    
       
 

 ';(!


   
 
  
 
/      
 


 
  
            


v  


  "   HelloWorl.ava HelloWorlA let.ava!


       

  
8

rom t> avac HelloWorl.ava

rom t> avac HelloWorlA let.ava

$   
     
 
"   
     


  


  "0"  

  

 
        


   
8

rom t> avac retor ro ram)/amafle.ava


  
   !     
   
 

     "

.class! 

    


   

   
         0         



$     1
 5 
    
 m ort $  
       


    


   "         



           


  
 "  Y         

Gra hcs     


 ava.awt.Gra hcs!    

   

ava.awt.Gra hcs

+   0 




 
 ulc class. $
   


         +       
 
   #


   Y   
  +
 ulc     "     

 


      .



     

  


          *   1


 5


  
 extes %  

 
  

    "
0"
   
 extes* 


 
     
extes         



+  
     
 ulc statc vo ma Str  ar s) 

ulc vo at Gra hcs ) +      


       



      
 
    

 


   

+       "      


  *  


         
   ma     
 


  

    
     
! 
   
    

 
  
     at+
 ulc     "  

  
 ulc         /  
    

    


  
 rvate  rotect   
  

$   1
 

 
 statc   
     
  %    



 ma
    
        
     

!

   
 
     
 

    *   
 ma

    !  
        Str  ar s!    ar s     

         Str      


      
0  
  

        


  
    
  

 


!  
  
 
ma      

+         
     


! 
     


 


   
   
 
    



  
      
      

         



 +  
   


     
    
 


rtl   at 


  
   
     
     


   
   
8

| : 


  *   System.out Gra hcs 

5| /  
 
  *    rtl  at

;|   
        " 
          


  ! 
  


*  1
! 
 System.out. rtl A a Kaar Dua?); 
  

 out      System     


 rtl    out  

 
   
 A a Kaar Dua?      1
 5! 


.rawStr A a Kaar Dua? 5 25);  


         


rawStr       
A a Kaar Dua?´ 5 25);
ã   


       
    Y        
!  
  
  

      .


   
      !



  
  
ava HelloWorl   
   A a Kaar Dua?

 
  '
 

 ! 

    (  


 

 
  
 "%1      <
   


 
 "%1 
     
 



<HTM
>

<HEAD>

<TIT
E>°oa A let</TIT
E>

</HEAD>

<BODY>

<APP
ET °ODE=HelloWorlA let.class WIDTH=50 HEIGHT=25>

</APP
ET>

</BODY>

</HTM
>

 hellowor.html   


    "0"

.ava   .class    .


   
 
        " %1


     Y  0 
 
  
 a letvewer

amafle.html 



ã ! " #ãºã

$
 $    #"0-     
        

 

  
   
   .
     

 !          
 
   8

 $
 #"0-


   
#"0-

"'(
=


 
>
?

=


 
5>
?

+
8

—| v      
        v   


 
   
        
 
 
—|     

   
              
 
—| +       0

        


$

+  8
$
"    
 !@Y   !  

 
  
    
     
       

 
5@

.

 
   !  
A


5$
#"0- 
+

+      
"          
 

  
 

 #"0- 
+

"'BB4CC5
(
=


 
>
?


+
8

—| v   %!    &! 


      
        
   %           
   
    

 
—| : 
@±±@    
          c% 
       *  
   

  
 

—| : 
@ÈÈ@    
        Ñ%   
     
  
 *  

    
$
—| +       0

        


$



;$
/
#"0-

$   #"0-  /
    
 
         
  
 
      !  
 
 
!      
   * 

             

  
 0
         

/
"    
"     
"   
   

/
"   8

"'(
=
"'0(
=


 
>
?

=


 
5>
?
?

=
"'50(
=


 
5>
?

=


 
55>
?
?

+  8
$
/
#"0-   
 !

—| @Y      !      0   !    


  

 
@  0 
!       


 
5@
—| @Y      
!      50   !    
  

 
5@  50 
!       


 
55@

 

$
           Y      „  $
 „ 
        !

   "
   
        

  

$

   
  


„  es res) {


„ la
ertah
 ;
„ la2
ertah2
 ;
„ la
ertah
 ;

  
ertah_la
}

*  


 
        es res        0 
   "
    
 „ Y     
   
 !      

     „

       
  

     Y 
 

 !       
 
 

   

  

       


       
 '
!  
!    (

  
!    

        
  
       

Str 
$
 

 
       
! 
 
 
  
          „    



 
     

   
 
  !      
    

          

    
  

  !



8

„  )
„ 
System.out. rtl A a terseut erla );
 ;
„ 2
„ 
„ 4
„ 5
System.out. rtl A a terseut erla 2  4 atau 5);
 ;
„ 6
„ 7
„ 8
System.out. rtl A a terseut erla 6 7 atau 8);
 ;

  
System.out. rtl A a terseut ta erla  - 8);
}

   
      
 
        
    
           
 
   
  +


    
  
 
   
 
    
 


  
        

Y    


 
 ma )     Y  ! 
   
 
Str  ar s!            
  
                            
     * 

       
          
   

Y   
  
       1 9!  
   

   
   1 9  
 @ 0@
 @
 9"D   @ *  

   
      @0@
 @9"D   @            
  
   

 
$
     !
  =?
  
 0
   *  Y  ! 
   

 >     
  


 x > 0);
ertah

  
  

      9EF6

$
         
"
  
 
 
     
    



  = ;  <= 0; );


System.out. rtl hallo);

    
 

 69  !  
    
 
+ G+  
 @>@
 " 
     
     
0          $
 System.out. rtl hallo)
        
   "!   
     9  

 
% 

        
 Y     
    
   !

 
0 
   

 
Y  ! 
      
  
 
!

...   
 
      
 
   
'
 
  
   (! „
 
 



 
0
 


Ñ '   
$  
   
         
    "           
    +

 

                   
 0

      


   
   
       

$     
!
            

@
@ : 
  
     ! 
  0
"      *     
!0"
  
  

!     " 



     

   
! 
    

 
    


*         


      
          
  !    "

  
       

    

 




!$:           :  
 
                '   

( 
 
' 
 
( 
      

               $:!  



Y  
          $:! 
    Y     
"
 
     
 .
    "
!
  
      

   

:
 

  +

      
  
  0    


           


Y         


!       G1  
 
            
 
 G 
 
 


 0
    !         

@„@       
 ! G

 

         
!
 


 !  @„@   
   ! 
   !      %  '    (
   !   !  ! ! !       0  

  @  
@

   !


  0  !
 
!
!
 !
  !
  !      

  !  !
  !  0 

*   
     !     
 
 


 
 !       
  0

 
 
      


! 
     
 $ 
     8:
     
     !  

      

+


   !         
    
   

  

 „„ DataPeuu {
„ Str ama;
„  umur;
}

$          !    


  
   
DataPeuu.ama DataPeuu.umur%      
   !  

 


  


!  
   


    



 + DataPeuu           


  

  


     0

8

 „„ DataPeuu {
Str ama;
 umur;
}

*   
       *
$    DataPeuu.umur!
        


 DataPeuuY !
     

       !   
  


          @ @ @ @+

   
  @   @  
   
 

    
  
     !
   
     
 
     !
  





  
       
     

   


+

    
        





        ).#   
   
 !   

 :+!    0 


        


    
  0  
 ':+! 
 (
     0 


 
  
 

  

&  
   
       
 
'*  
$: 

 
(
     DataPeuu
!  


  
!   
 

  DataPeuu!@ @ @ @
    
  



$
 

   
 
 
 
   

!  


 
     !  

  
 
 !  
     
 0 


    

!      
 !
   

   l ) 0 
       
  0 
 

  

 


    

 0

 
    
             


!
  
  
0

 


         
 
&   



    
     
 




    
 
 !             
 
  
 

  
   
    +
  
    
Mur!  
    " 

  
 "
  
 

 „„ Mur {
Str ama ; ‰‰
 

   la la2 la; ‰‰
 

  

   htu ataata ) { ‰‰
    
 


  la  la2  la) / ;


}
}

+

    
 

   


! 
  
      
  
*"  
     
   
 !      
  ama!la!la2! 
la!    

  htu ataata )
    
 
0
  0 '   
   
 0 (

*  Y  !    
 
! 
   
 
   



 Y        
 
 
 
    
   
!    
"      
   
" 
  !   "     
 
8

Mur amr;

 

  
   

#*+ 
 #
 !
   H  

$
8
c '       $ 
 
  (   $v  
        $

:
   
! 
  
   
   "   
   amr      

 Mur 
   
!   

8

amr =  Mur );

   
    
  Mur&  amr  
 "     
 

      amr      


   Mur
*  



  ama!la!la2! la&  

   amr.ama!amr.la!amr.la2! amr.la'#

 
    !  

   
    


!   
 
       
 
!     

        (

  !  


8

System.out. rtl Ha   amr.ama   . la Aa aalah );


System.out. rtl amr.la);
System.out. rtl amr.la2);
System.out. rtl amr.la);

$ 
   
   0    amr

  
   

0
  
     
amr.htu ataata )   
  

0
 

! 


  8

System.out. rtl la rata-rata Aa aalah   amr.htu ataata ));

1   !
     amr.ama 
     
 

! 
 
   
    
     
amr.ama.le th )

+
     
   
amr 

    
  
"   *   

     
' "(,"
  Y    @ @* 
 
  @ @       
8

amr =  ;

* 
       "  

 amr ==  ) . . .

Y 
  "!  

  !

    
  
      

!  
        
  

     amr !  

    
  amr.la

Y   


    "   !  
 0
 
     !           @  
9
@

 

  
      8

Mur mr mr2 mr mr4; ‰‰ 


  
  


mr =  Mur ); ‰‰       
  
 
 


      
mr2 =  Mur ); ‰‰       
  
 
 


      
mr = mr; ‰‰ 


  
 
  
mr4 =  ; ‰‰ 
 


  

mr.ama = Ahma Surahmat; ‰‰ 



   


mr2.ama = Ham Samsu;


 
      

!   0   
  

 
  
8


)  

        
0
     
:
    
   
+
 
  "

!        
        



&  mr4  !  


      0  $     
;       #   h!  8

            '   



 $    
  $

+
  
@mr = mr;@ !
      
 


mr        
   
 mr+   


     mr.ama mr.ama         
 !    mr.ama @Y  Y 
@!  mr.ama  @Y  
Y 
@

  !       '       

+
      
FF AF 
    

   

  0   !    
  
  

  "Y  
"   ! 
  


      
    # 
       
    
  
        

.
   !       
 
! 
    
@mr.la == mr.la && mr.la2 == mr.la2 && mr.la ==
mr.la && mr.ama.equals mr.ama)@

 

 
     
       
   
 
 
       
 FF   
      
   
  
 
   

  
  
  #
FF        
!

     
   
    

.

   
!

    Str .equals )    
 
  
     
        
 
  
  


  !    


@
@.
        
@
@! 
    


salam.equals Selamat)

+        


           
  " # 
   

    
   !  
  
       
  

  *     


          
     

 
   


        
 @  @

     

    !       

!  


   

+
    
   
  


 Mur mr =  Mur );


mur.ama = Ahma Basr;

$
   
      

 
    
 


Mur mr =  Mur );


mr = mr; ‰‰!"#$ " 
      




 '


þ  
Packages   Y& 
    class  interface
  
 
I
       
 
class  
interface           "    


þ  

  
    class     package   
  !     
package   class

  
$     !    Y&  
package java.lang.*,
   
    class  

 #
  
      
package   
$   
package 
    
  8
 
EnamaPaket>>
  
 !      class   package

!       
package   
8
 
   
>
 
   
J>
  
 
  
  
class    "
 package!     
   
  class
 
    package java.awt
       
package       "
package    
%          
package 
    object  class 8
   
>



5¢

$   "  !
 ""0"       
"  0 ! 
0 
!
  
 
           
   "  



        
     
 !
       
8
 
  ,  I>
 
  
J>



;¢   
    
"           
 

    
     
 class, 
 
interface    
syntax 
E
" * 
K88F
E "K
" E K=
E


* 
KJ
LE "KE
 KE K'E  
KJ(>MJ
?

    public 
 
"    public.

þ þ þ  
ecara mutlak atribut adalah static dan final dan harus diinisialisasi dengan
nilai konstanta. eperti mendeklarasikan class teratas, acces modifier yang
valid hanyalah public dan package(yakni jika tidak ada acces modifier
mengawali kata kunci class).
    
  
"  
    
   
 
implements.  
 
   
   


"       
   

" 


 
             
    
" 

" #
" =

'(>
?
    
#
" =

'(=

 
 
'@#
"  
@(>
?
 
'(=

 
 
'@
 
@(>
?
?
  5  
#
" =

'(=

 
 
'@
  

@(>
?
?
 #
" * =


 '
 LM(=
  F '(>
 5 5F 5'(>

'(>
 
'(>
5
'(>
?
?
:

$ 8
8N* 
 

N 

N* 
K  
#
" *   
8N* 
 

N 

N* 
K  
#
" * 
#
"  


 


  




Ñ Ñ  Ñ 

Ñ Ñ

w 
  
 
      
 
 


 
 
w 
 
   
   
w   

     
    
 !
    

Ñ 

w  


 
 
    " 

   
 " #
$
w     

     
    
 !
  

%&

" '
 (
 "   )
 (
* $$

+
" 
,
-
"   
 '
 (
 "   )
 (
* $$

+
" " ,
-

  Ñ     


 .$/$'

 " " *  (

 0 1 2

 0 1 2

 3 1 2

 3 1 2
 "   * 
 0
 0
 3
 3 (
 $0 1 0
 $0 1 0
 $3 1 3
 $3 1 3
-
 "   * '
 4 '
 !  (
0 1 4$
0 1 4$
3 1 ! $
3 1 ! $
-
 "   * '
 4
 /
  (
0 1 4$
0 1 4$
3 1 0 5 /
3 1 0

  "* (
* $$
6*  76 5 0 5 6 6 5 0
* $$

6 6 5 3 5 6 6 5 3 5 686
-
 "  "   
*
9:  
  (
*  " 1
/ * 
* $$

6;   


 3<3<

<2<26
"$* 3< 3< <2 <2
"$"* 
* $$


* $$

6;   


 0202 


 32326
"$* 
/ '
0202
/ '
3232
"$"* 
* $$


* $$
6;   

0 
 0202

 <2<26
"$* 
/ '
0202 <2 <2
"$"* 
--








 
+-#$.1/

 Y              
  *
  

  
   
        
" 
   

 $
"  
 
 
 
"   
    
      !"0 
 
     
 
 
      
  
 "     
 
 
 "     
   
 "    
     
 
      

    
   
      

 $        ! 
"! 
 
   "  
   


 
  
          
  


    
     

 $              
 
    "  !
              

 :         
 "     
  
   

 "