Boa tarde galera.
To iniciando no java… ai tava fazendo um programinha… para somar,
tentei fazer sem Eclipse, na tora no bloco de notas… qndo dei o " javac "
pediu pra eu usar o -Xlint… usei… + nao pegou tb…
ai tentei rodar no Eclipse rodou direitinho…
Vejam o Código:
import java.io.DataInputStream;
public class testes {
public static void main ( String args [] ) {
int num1 = 0, num2 = 0, soma = 0;
System.out.println( "Entre com 1 número: " );
num1 = ler(num1);
System.out.println( "Entre com 2 número: " );
num2 = ler(num2);
soma = num1 + num2;
System.out.println( "A soma é: " + soma );
}
// Rotinas para entrada de dados
// ler - ( BYTE )
public static byte ler ( byte x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x= Byte.valueOf(valor).byteValue();
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( SHORT )
public static short ler ( short x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x= Short.valueOf(valor).shortValue();
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( INT )
public static int ler ( int x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x= Integer.valueOf(valor).intValue();
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( LONG )
public static long ler ( long x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x= Long.valueOf(valor).longValue();
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( FLOAT )
public static float ler ( float x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x= Float.valueOf(valor).floatValue();
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( DOUBLE )
public static double ler ( double x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x= Double.valueOf(valor).doubleValue();
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( CHAR )
public static char ler ( char x ) {
char y = ' ';
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
x = valor.charAt(0);
}
catch(Exception e) {System.out.println("ERRO");}
return (x);
}
// ler - ( STRING )
public static String ler ( String x ) {
String valor="";
DataInputStream in = new DataInputStream(System.in);
try{
valor=in.readLine();
}
catch(Exception e) {System.out.println("ERRO");}
return (valor);
}
}