Check inputan integer tidak boleh kosong menggunakan if.
adek yg lucu, nanyain sesuatu tentang java . . .
ya sebisanya aja ya . . . ntaah ni bener pa nggak . . .tp menurutQ ya sprti ini . . .
mg bermanfaat bt adek yg lucu . . .heheheh ckckckckckkk
& bermanfaat buat semuanya . . .amiin
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package appgambar;
import javax.swing.JOptionPane;
/**
*
* @author Christanti
*/
public class diIsiHarusIntegerSajaPakekIf {
public static void main(String[] args) {
String Nilai = JOptionPane.showInputDialog("Masukkan nilainya = ");
if (Nilai.isEmpty() == false) {
try {
int N = Integer.parseInt(Nilai);
System.out.println("ini angka = " + N);
} catch (Exception e) {
System.out.println("Masukkan angka");
}
}else {
System.out.print("Mohon di Isi");
}
}
}
Selamat mencoba . . .





Tidak ada komentar:
Posting Komentar