Cara Menjalankan Program Dan membuat Program Java

Contoh satu :
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Samsung
 */
public class MobilBaruBeraksi {
   
    public static void main(String[] args) {
        MobilBaru mobilku = new MobilBaru();
       
        mobilku.warna = "Kuning";
        mobilku.tahun = 2007;
        mobilku.tampilMobil();
       
       
       
       MobilBaru mobilmu = new MobilBaru();
     
       mobilmu.warna = "Merah";
       mobilmu.tahun = 2015;
       mobilmu.tampilMobil();
       
    }
   
}

Contoh Dua :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lat1joptionpane;

import javax.swing.JOptionPane;

public class Lat1JOptionPane {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        String name = "";
        name = JOptionPane.showInputDialog("please Enter Your Name") ;
        
        String msg = "Hello " + name + "!";
        JOptionPane.showInputDialog(null, msg);
    }
}

Posting Komentar

0 Komentar