Created
January 10, 2013 14:35
-
-
Save endymuhardin/4502471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultivalueReturn { | |
public static void main(String [] xx){ | |
// bagaimana supaya method ini mengembalikan banyak value? | |
// value yang diinginkan : kode, nama, harga | |
cariProduk("biskuit"); | |
// jawaban : buatkan classnya | |
Produk p = cariProduk("biskuit"); | |
} | |
private static Produk cariProduk(String nama){ | |
Produk p = new Produk(); | |
p.kode="B-001"; | |
p.nama="Biskuit Rhoma"; | |
p.harga=new BigDecimal("10000.00"); | |
return p; // satu object p berisi banyak value | |
} | |
} | |
class Produk { | |
public String kode; | |
public String nama; | |
public BigDecimal harga; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment