 
			
				21/11/2009, 11:14
			
			
			     |  
      |    |    |    Fecha de Ingreso: noviembre-2009  
						Mensajes: 5
					  Antigüedad: 16 años Puntos: 0     |        |  
  |      Respuesta: Leer y sumar        Hola tengo este código:   
import java.io.*;   
public class Sumar { 
 public static void main(String args[]) { 
 BufferedReader teclado; 
 String linea; 
 int a; 
 int b; 
int suma;   
 teclado = new BufferedReader(new InputStreamReader(System.in));   
 System.out.print("Introduce a: ");   
 try {  
 linea = teclado.readLine(); 
  try {  
  a = Integer.parseInt(linea); 
  } 
  catch (NumberFormatException e) { 
 System.err.println("ERROR"); 
 } 
 } 
 catch (IOException e) { 
 System.err.print("ERROR"); 
 } 
System.out.print("Introduce b: ");   
 try {  
 linea = teclado.readLine(); 
  try {  
  b = Integer.parseInt(linea); 
  } 
  catch (NumberFormatException e) { 
 System.err.println("ERROR"); 
 } 
 } 
 catch (IOException e) { 
 System.err.print("ERROR"); 
 }   
suma=a+b; 
System.out.print("El resultado es: " + suma);   
} 
}     
Quiero hacer la suma en un método. Como se hace?           |