Archive

Posts Tagged ‘OOP’

Get Connection MySQL

January 2, 2010 Leave a comment

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

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class CobaSQL {

private static Connection conn;

public static void main(String[] args) {
try {
conn = DriverManager.getConnection(“jdbc:mysql://localhost/db_kursus?user=root&password=”);
System.out.println(“Driver ditemukan. Koneksi berhasil!!!”);
} catch (SQLException ex) {
// handle any errors
System.out.println(“SQLException: ” + ex.getMessage());
System.out.println(“SQLState: ” + ex.getSQLState());
System.out.println(“VendorError: ” + ex.getErrorCode());
}
}
}

Basic Client-Server Application With Netbeans

January 2, 2010 Leave a comment

In this tutorial, we will extend our basic client/server address application II using sockets. This tutorial assumes that you have read and completed the following tutorials.

Download : http://www.ziddu.com/download/7984176/bdcs.zip.html
Source : http://www.sumtotalz.com/TotalAppsWorks/BasicClient_Server_III_DL.html

Mencari Nilai Terbesar Dengan JOptionPane

December 31, 2009 Leave a comment

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

import javax.swing.JOptionPane;

/**
*
* @author Arin
*/
public class MencariNilaiTerbesarJOptionPane {

public static void main(String[] args) {
int angka[] = new int[10];
int x = 0, z = 0;
String y = “”;

for (x = 0; x < 10; x++) {
y = JOptionPane.showInputDialog("Masukkan angka ke " + (x + 1) + ": ");
angka[x] = Integer.parseInt(y);
}
Read more…

Contoh Program Buku Alamat dengan Array

December 31, 2009 Leave a comment

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

/**
*
* @author Arin
*/
public class BukuAlamat {

public static void main(String[] args) {
String[][] entry = {{“Florence”, “735-1234″, “Manila”},
{“Joyce”, “983-3333″, “Quezon City”},
{“Becca”, “456-3322″, “Manila”}};

int x = 0;

for (x = 0; x < 3; x++) {
System.out.println("Name : " + entry[x][0]);
System.out.println("Tel. # : " + entry[x][1]);
System.out.println("Address : " + entry[x][2]);
System.out.println("");
}
}
}

Download Source Code : http://www.ziddu.com/download/7961146/BukuAlamat.zip.html

Contoh Program Array

December 31, 2009 Leave a comment

package SL275;

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

/**
*
* @author GW_SBY
*/
public class ArrayDemo {

public static void main(String[] args) {
int[] anArray; // declares an array of integers

anArray = new int[10]; // allocates memory for 10 integers

anArray[0] = 100; // initialize first element
anArray[1] = 200; // initialize second element
anArray[2] = 300; // etc.
anArray[3] = 400;
anArray[4] = 500;
anArray[5] = 600;
anArray[6] = 700;
anArray[7] = 800;
anArray[8] = 900;
anArray[9] = 1000;

System.out.println(“Element at index 0: ” + anArray[0]);
System.out.println(“Element at index 1: ” + anArray[1]);
System.out.println(“Element at index 2: ” + anArray[2]);
System.out.println(“Element at index 3: ” + anArray[3]);
System.out.println(“Element at index 4: ” + anArray[4]);
System.out.println(“Element at index 5: ” + anArray[5]);
System.out.println(“Element at index 6: ” + anArray[6]);
System.out.println(“Element at index 7: ” + anArray[7]);
System.out.println(“Element at index 8: ” + anArray[8]);
System.out.println(“Element at index 9: ” + anArray[9]);
}
}

Follow

Get every new post delivered to your Inbox.