/**
* Title : Pass by value
* Deskripsi: Mendemonstrasikan cara melewatkan argumen secara nilai/value ke method
*/
public class PassByValue
{
/** Main method */
public static void main(String[] args)
{
// Mendeklarasikan dan menginisialisasi variable
int bilangan1 = 3;
int bilangan2 = 7;
System.out.println(
"Sebelum memanggil method tukarBilangan :\n" +
"----------------------------------------\n" +
"Nilai bilangan1 adalah " + bilangan1 + "\n" +
"Nilai bilangan2 adalah " + bilangan2 + "\n");
// Memanggil method tukarBilangan untuk menukar nilai dua variabel; bilangan1 dan bilangan2
tukarBilangan(bilangan1, bilangan2);
System.out.println(
"Setelah memanggil method 'tukarBilangan' :\n" +
"----------------------------------------\n" +
"Nilai bilangan1 adalah " + bilangan1 + "\n" +
"Nilai bilangan2 adalah " + bilangan2 );
}
/** Method untuk menukar dua bilangan */
static void tukarBilangan(int a, int b)
{
System.out.println("Saat ini kendali program berada di " + "dalam method 'tukarBilangan'\n");
System.out.println("Sebelum proses penukaran :\n" +
"------------------------------\n" +
"Nilai a adalah " + a + "\n" +
"Nilai b adalah " + b + "\n");
// Menukar bilangan a dengan b
int temp = a;
a = b;
b = temp;
System.out.println("Kendali program masih dalam method " + "'tukarBilangan'...\n");
System.out.println("Setelah proses penukaran :\n" +
"------------------------------\n" +
"Nilai a adalah " + a + "\n" +
"Nilai b adalah " + b + "\n");
System.out.println("Kendali program keluar dari" + "method 'tukarBilangan' :\n");
}
}
Subscribe to:
Post Comments (Atom)
1 comments:
hi dee hi dewimulyaniitdanbahasajepang.blogspot.com blogger discovered your website via Google but it was hard to find and I see you could have more visitors because there are not so many comments yet. I have found site which offer to dramatically increase traffic to your site http://cheap-mass-backlinks.com they claim they managed to get close to 4000 visitors/day using their services you could also get lot more targeted traffic from search engines as you have now. I used their services and got significantly more visitors to my site. Hope this helps :) They offer best services to increase website traffic Take care. Richard
Post a Comment