Computer & Network Engineer
الذهاب إلى القناة على Telegram
إظهار المزيد
لم يتم تحديد البلدالفئة غير محددة
983
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
لا توجد بيانات30 أيام
أرشيف المشاركات
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();
}
