Daftar

[ask] about exception handling java


Programming & Web Coding, web, aplikasi, dan karier developer.

Balas
 
Alat Thread
Servermaster Servermaster sedang offline
#1
Member Aktif Tanggal Bergabung: Nov 2011 Post: 257 Rep Power: 16 Servermaster mempunyai hidup yang Normal
Default [ask] about exception handling java
Tanya gan, berkaitan dengan exception handling...

Jadi codenya begini di kelas main :

<div style="margin:20px; margin-top:5px">
Code:

public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Mobil mob = new Mobil();
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
int x=0,panjang = 0,lebar = 0;
String merek = "", platNo = "", bahanBakar = "", warna = "";
LinkedList listKomponen = new LinkedList();
do{
try{
System.out.println("=====MENU=====\n"+
"1. Masukkan Mobil Baru\n"+
"2. Tampil Semua Data Mobil\n"+
"3. Keluar \n Pilihan anda : ");
x = input.nextInt();

switch(x){
case 1 :
try{
System.out.println("merk : ");
merek = b.readLine();
System.out.println("Plat No ; ");
platNo = b.readLine();
System.out.println("Warna : ");
warna = b.readLine();
System.out.println("Bahan bakar : ");
bahanBakar = b.readLine();
System.out.println("Panjang : ");
panjang = input.nextInt();
System.out.println("Lebar : ");
lebar = input.nextInt();
checkMerk(merek, listKomponen);
checkBB(bahanBakar, listKomponen);
checkLebar(lebar);
checkPanjang(panjang);
checkPlat(platNo, listKomponen);


}
catch(merkException me){
System.out.println(me.getMessage());
}
catch(bbException bbe){
System.out.println(bbe.getMessage());
}
catch(rangeException re){
System.out.println(re.getMessage());
}
catch(platNoException pne){
System.out.println(pne.getMessage());
}
catch(Exception E){}
mob = new Mobil(merek, warna, platNo, bahanBakar, panjang, lebar);
listKomponen.add(mob);
break;
case 2 :
printListKomponen(listKomponen);

break;

}
}
catch(Exception E){}

}
while(x!=3);

}

public static void printListKomponen(LinkedList
Balas


Aturan Posting
Kamu tidak boleh membuat thread baru
Kamu tidak boleh membalas
Kamu tidak boleh mengirim lampiran
Kamu tidak boleh mengedit post kamu

BB code Hidup
Smilie saat ini Hidup
Kode [IMG] adalah Hidup
Kode HTML adalah Mati


Terkait
Thread Pembuat Thread Forum Balasan Postingan Terakhir
tanya masalah j2me..eror nullpointer java/lang/nullpointer exception Permenkaret Programming & Web 0 20 Nov 2011 12:18 PM