java 二维数组位置_请完成下列Java程序:查找一个矩阵中的鞍点,对于一个二维数组中的鞍点,该点位置上的元素在该行上...
請完成程序,首先由一個類simple實現Serializable接口,并有三個成員變量,分別為int型、double型和String型,可以用toString的方法顯示這三個成員變量。在main方法中創建這個simple的持久對象,根據用戶在命令行輸入的三個參數來設定其中成員變量的值。然后,將這個對象寫入名為TheSerial.data的文件中,并顯示成員變量。最后從文件TheSerial.data中讀出三個成員變量并顯示出來。
注意:請勿修改main()主方法和其他已有語句內容,僅在橫線處填入適當語句。
import java.io.*;
class TheSerial implements Serializable
{
private int intvalue;
private double doublevalue;
private String string;
The Serial ()
{
intvalue=123;
doublevalue=12.34;
string="Serialize Test";
}
public void setDouble(double d)
{
doublevalue=d;
}
public void setInt(int i)
{
intvalue=i;
}
public void setString(String s)
{
string=s;
}
public String to String()
{
return("int="+intvalue+" double="+doublevalue+" string="+string);
}
}
public class simple
{
public static void main(String[] args)
{
The Serial e1=new TheSerial();
TheSerial e2;
try
{
e1.setInt(Integer.parseInt(args[0]));
e1.setDouble(Double.parseDouble(args[1]));
e1.setString(args[2]);
}
catch(Exception e)
{
e1.setString(e.getMessage());
}
System.out.println(e1);
try
{
FileOutputStream S=new FileOutputStream("TheSerial.data");
ObjectOutputStream OS=new ObjectOutputStream(oS);
______;
}
catch(IOException ioException)
{
System.out.println (ioException.getMessage ());
}
try
{
FileInputStream iS=new FileInputStream("TheSerial.data");
ObjectInputStream IS=new ObjectInputStream(iS);
______;
System.out.println(e2);
}
catch(IOException ioException)
{
System.out.println(ioException.getMessage());
}
catch(ClassNotFoundException cnfException)
{
System.out.println(cnfException.getMessage());
}
}
}
請幫忙給出正確答案和分析,謝謝!
總結
以上是生活随笔為你收集整理的java 二维数组位置_请完成下列Java程序:查找一个矩阵中的鞍点,对于一个二维数组中的鞍点,该点位置上的元素在该行上...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何添加局域网共享打印机如何添加局域网共
- 下一篇: 千万别买某多低价显卡千万别买某多低价显卡