Computer & Network Engineer
Ir al canal en Telegram
Mostrar más
El país no está especificadoLa categoría no está especificada
983
Suscriptores
Sin datos24 horas
Sin datos7 días
Sin datos30 días
Archivo de publicaciones
myButton.setBackground(Color.WHITE);
myButton.setForeground(Color.RED);
FileOutputStream out = new FileOutputStream("ObjectData.dat");
ObjectOutputStream ostream = new ObjectOutputStream(out);
ostream.writeObject(r);
RandomAccessFile randomFile =
new RandomAccessFile("Customers.dat", "rw");
try{
int n = getValueFromFile();
} catch ( IOException e){
System.out.println(e.getMessage());
} catch ( FileNotFoundException e){
System.out.println(e.getMessage());
}
public int getValueFromFile() throws IOException, FileNotFoundException {
}
public class NegativeNumber extends Exception {
public NegativeNumber()
{
super("Error: Negative number");
}
public NegativeNumber(int n)
{
super("Error: Negative number: " + n);
}
}
public static int arraySearch( int[] array, int value) throws Exception {
int index = -1;
for ( int i =0; i< array.length ; i++){
if ( array[i] == value){
index = i ;
break;
}
}
if ( index == -1 ){
throw new Exception("Element not found.");
}
else
return Iindex;
}
+1
هنا ترتيب ال catches غلط المفروض نبدأ بالتخصيص بعدين العام ، المفروض كدا الحل..
try
{
number=Integer.parseInt(str);
}
catch (IllegalArgumentException e)
{
System.out.println("Bad number format.");
}
catch (NumberFormatException e)
{
System.out.println(str + " is not a number.");
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
نفس الشيء هنا الترتيب خطأ المفروض catch قبل finally... المفروض كدا
try
{
input = inputFile.nextInt();
}
catch (InputMismatchException e)
{
System.out.println(e.getMessage());
}
finally
{
inputFile.close();
}
