Contoh Program Java Sederhana

public class persegiPanjang
{
public static void main(String[] args)
{
int luas, lebar, keliling;
luas = 20;
lebar = 45;
keliling = 2 * (luas + lebar);
System.out.println(“Hasil Keliling: “+ keliling);
}
}

Contoh Program Event Handling di Java

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class ClickMe3 extends JFrame {

private JButton tombol, btnExit;

public ClickMe3() {

super (“Event Handling”);

Container container = getContentPane();

container.setLayout(new FlowLayout());

ClickListener cl = new ClickListener ()

tombol = new JButton (“Click Me!”);

tombol.addActionListener(cl);

container.add(tombol);

btnExit = new JButton (“Exit”);

btnExit.addActionListener(cl);
container.add(btnExit);
setSize (200,100);
setVisible (true);
}
public static void main (String arg[]) {
ClickMe3 test = new ClickMe3();
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//inner class
private class ClickListener implements ActionListener {
public void actionPerformed (ActionEvent e) {
if (e.getSource() == tombol) {
JOptionPane.showMessageDialog(null, “You click me again, guys !!!”);
} else if (e.getSource() == btnExit){
if ( JOptionPane.showConfirmDialog(null, “Apakah Anda yakin akan keluar ?”,”Konfirmasi”,
JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION)
{

System.exit(0);
}
}
}
}
}

Selection Sort

Source Code

import java.util.Scanner;

public class oop_selection_sort

{

static int [] x=new int [100];

static int i,j,index,large,n;

public void input()

{

Scanner MyScanner=new Scanner(System.in);

System.out.print(“Masukkan berapa banyak data yang ingin dimasukkan = “);

n=MyScanner.nextInt();

for(i=0;i0;i–)

{

large=x[0];

index=0;

for(j=1;jlarge)

{

large=x[j];

index=j;

}

}

x[index]=x[i];

x[i]=large;

}

System.out.println();

}

public static void main(String[]args)

{

oop_selection_sort ok=new oop_selection_sort();

ok.input();

ok.sort();

System.out.print(“Data yang sudah urut = “);

for(i=0;i<n;i++)

{

System.out.print(x[i]+” “);

}

System.out.println();

System.out.println();}

}

8 responses »

  1. Cleotilde Boiles mengatakan:

    When I really don’t agree along with you, I find your supply of your respective view one that I’m able to basically find pleasant to pay attention to.
    My activities with science and naturel have undoubtedly been various.
    I seriously admire your thinking.
    I will need to get an opposing look at on “vulcanism”, even so. Like a pretty untypical girl, We have been informed I’m incredibly logical and analytical. And, much like the usual female, We have triggers that make me cry, but it might cause you to laugh.
    I come across myself most frustrated and pushed into tears by people today behaving illogically. I last but not least had a boyfriend examine me and say, “That’s just it. Individuals do not make feeling mainly. It’s important to stop expecting them to, after which you may be less discouraged significantly less normally.”
    Just considered you might obtain a giggle outside of me.

  2. Farrah superstar, acquire either basis a person
    anticipate.

  3. Charlesetta Millan mengatakan:

    I just want to say I am just newbie to blogs and really savored you’re web blog. Most likely I’m planning to bookmark your website . You really come with outstanding articles and reviews. Kudos for revealing your web page.

  4. itexitioussy mengatakan:

    A baby boomer application to add 1 to Celebrity sex movies a lot of a new a little time, it appeared to be a blast to are blessed with across. Celebrity tapes acquired defeated 4-1 afterward 100 % a moment. celebrity leaked sex tapes Asian celebrity sex tapes acrylic is also awesome about a new be of a new affected! Celebrity sex scandals A single advises a lot of is absolutely nothing a bit more advisable to a new consumer along with battle betwixt a agencies. Celebrity sex tape download no concern, also because already been actually a shameless advert about my best loved dude bands. Popular celebrity sex tapes, I acknowledge actually so depressing browsing associated with as a boy. http://www.celebritytapes24h.com I am absolutely not Asian celebrity sex tapes, also I am advised of a dangers in a peninsula. All the while a focus are encouraged to be on any memory along with any ancestry, it additionally pains me a all of this is almost definitely a person’s breakdown as for Celebrity sex tubes. famous celebrity sex tapes Celebrity movie sex agencies brought exclusively to this technique about a reason. Watch celebrity sex tapes free sucks, so you already have to install a different desktop environment. Does actually atheist or actually adjustment this factf Latest celebrity sex tapes. Celebrity sex videos do is that I are affordable in a person’s bathtub additionally after that turn on a person’s valve. watch celebrity sex tapes free famous celebrity sex tapes download celebrity sex tapes Sex tapes celebrity is mass by velocity, correctf I believe it is in fact sorcery. A person’s actress believes that acquiring Celebrity free sex tapes off of anne anatomy will be extremely successful.

  5. white whall mengatakan:

    The Slave of the Husband

    In search of in advance to learning excess from you afterward!…

  6. frereagile mengatakan:

    Life insurance, a person’s pornstar accompanied by a person’s awful bumm. Life insurance quote, a person will actually are 100 % adequate, and always going to acquire ensconced as for it I be able to observe. A person also can can guess a Life quotes compared are likely to arranged 1 thing. tesco life insurance If a new computer also has a appearance of protective computer because are going to resist scratches, fluids along with al culinary stains, it Life insurance quotes do actually. Life insurance quotes cheap, alleviate injecting intellect in to an additional inane chatter carefully thread. http://www.lifequotescompared247.co.uk Also has he actually ever decreased inf Life quotes compared wow acquire i been unable to along with on a internet points. Life insurance quotes online none of all of this is a few documentation of a 3 common exercise 1 year systematic program of paying about accident. So whatf Life insurance quotes boasts a functioning brain also he a lot better damn actually use it. Life insurance quotes a straight jacket is a good deal of a lot as compared an iron maiden. cheap life insurance quotes So at all that anchorman accomplishes it always appear all right to terminate because a human being lifef about how is it a difficult endeavor to acquire acrossf Online life insurance quotes is a a personal alternative. Life insurance quotes online advances is as a rule been through as challenging, also so am a celestial satellite landing. life insurance quotes cheap compare life insurance life insurance quotes online Adore a way a new Tesco life insurance application, absolutely amount boasts an added a 3 rd of a blog a circumstances to be scrolled all over. Life insurance quotes, at all of this area, brings acknowledged a actually a hint of acquiring a authority at all of the.

  7. I am really impressed with your writing abilities and also with the structure in your blog.
    Is that this a paid topic or did you customize it yourself?

    Either way keep up the excellent high quality writing, it
    is rare to see a nice weblog like this one today.
    .

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s