ch
Feedback
Computer & Network Engineer

Computer & Network Engineer

前往频道在 Telegram

显示更多
未指定国家未指定类别
983
订阅者
无数据24 小时
无数据7 天
无数据30 天
帖子存档
public constructor(){ setLayout(new GridLayout(5,10)); }
public constructor(){ setLayout(new GridLayout(5,10)); }

public constructor(){ setLayout(new FlowLayout(FlowLayout.LEFT)); }
public constructor(){ setLayout(new FlowLayout(FlowLayout.LEFT)); }

myButton.setBackground(Color.WHITE); myButton.setForeground(Color.RED);
myButton.setBackground(Color.WHITE); myButton.setForeground(Color.RED);

myWindow.setVisible(true);
myWindow.setVisible(true);

myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

myWindow.setSize(500,250);
myWindow.setSize(500,250);

كذا نكون خلصنا من اسئلة الكتاب لشابتر 11 وحبدأ باسئلة بشابتر 12

FileOutputStream out = new FileOutputStream("ObjectData.dat"); ObjectOutputStream ostream = new ObjectOutputStream(out); ostr
FileOutputStream out = new FileOutputStream("ObjectData.dat"); ObjectOutputStream ostream = new ObjectOutputStream(out); ostream.writeObject(r);

RandomAccessFile randomFile = new RandomAccessFile("Customers.dat", "rw");
RandomAccessFile randomFile = new RandomAccessFile("Customers.dat", "rw");

FileOutputStream fstream = new FileOutputStream("Configuration.dat");
FileOutputStream fstream = new FileOutputStream("Configuration.dat");

try{ int n = getValueFromFile(); } catch ( IOException e){ System.out.println(e.getMessage()); } catch ( FileNotFoundExceptio
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 int getValueFromFile() throws IOException, FileNotFoundException { }

throw new NegativeNumber(-5); OR throw new NegativeNumber();
throw new NegativeNumber(-5); OR throw new NegativeNumber();

public class NegativeNumber extends Exception { public NegativeNumber() { super("Error: Negative number"); } public NegativeN
public class NegativeNumber extends Exception { public NegativeNumber() { super("Error: Negative number"); } public NegativeNumber(int n) { super("Error: Negative number: " + n); } }

throw new IllegalArgumentException("Argument cannot be negative.");
throw new IllegalArgumentException("Argument cannot be negative.");

public static int arraySearch( int[] array, int value) throws Exception { int index = -1; for ( int i =0; i< array.length
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; }

The output is B D E
+1
The output is B D E

هنا ترتيب ال catches غلط المفروض نبدأ بالتخصيص بعدين العام ، المفروض كدا الحل.. try { number=Integer.parseInt(str); } catch (
+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 (InputMismatchE
نفس الشيء هنا الترتيب خطأ المفروض catch قبل finally... المفروض كدا try { input = inputFile.nextInt(); } catch (InputMismatchException e) { System.out.println(e.getMessage()); } finally { inputFile.close(); }