import
javax.swing.JOptionPane;
class
constructor {
private int
n1=0;
private int
n2=0;
public
constructor (int n1, int n2){
this.n1=n1;
this.n2=n2;
}
public int sumas(){
int suma=0;
suma=n1+n2;
return
suma;
}
}
public
class EjemploCONSTRUCTOR {
public
static void main(String[] args) {
int nn1=0;
int nn2=0;
nn1=Integer.parseInt(JOptionPane.showInputDialog("Ingrese
un numero: "));
nn2=Integer.parseInt(JOptionPane.showInputDialog("Ingrese
un numero: "));
constructor
ctr=new constructor( nn1 , nn2);
JOptionPane.showMessageDialog(null,ctr.sumas());
}
}
No hay comentarios:
Publicar un comentario