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();
}
