我正在创建一个类似于Banko applet的Java应用程序.当我点击"public void init()"方法时,我的表现很好.当我完成时,除了那之外所有编译.它告诉我添加@Override注释.我试过了,但每当我这样做,无论我把它放在哪里,编译器都会失败并出现以下错误:
找不到标志
符号:类覆盖
location:class aBomb.Bomb
我不知道是什么阻止了应用程序正常执行.:| 如果您在下面写的代码中找到了您认为应该更改的内容,请告诉我.我是Java的新手:(代码:
public void init() {
BorderLayout border = new BorderLayout();
setLayout(border);
JPanel top = new JPanel();
JLabel moneyLabel = new JLabel("Money : $");
moneyField = new JTextField("", 8);
moneyField.setEditable(false);
JLabel foundLabel = new JLabel("Found: ");
foundField = new JTextField("", 8);
foundField.setEditable(false);
restart = new JButton("Restart");
restart.addActionListener(this);
top.add(moneyLabel);
top.add(moneyField);
top.add(foundLabel);
top.add(foundField);
top.add(restart);
add(top, BorderLayout.NORTH);
board = new Board(this, ROW_COUNT, COLUMN_COUNT, BOMB_COUNT);
add(board, BorderLayout.CENTER);
setup();
setVisible(true);
}
Run Code Online (Sandbox Code Playgroud) 很长一段时间我一直在考虑这个问题.Vectors和之间有什么区别Arrays?我知道他们会做类似的事情,如果不是确切的话.
String[] array = new String[4];
Run Code Online (Sandbox Code Playgroud)
Vector<String> vector = new Vector<String>(4);
Run Code Online (Sandbox Code Playgroud)
arrays和vectors.使用其中一个是否有任何优点或缺点? 我有2条错误消息,无法确定它在问我什么。错误是:
Desktop \ Inventory Program \ InventoryPart1.java:93:找不到符号
符号:可变打印机
位置:类InventoryPart1
System.out.println(“ Item Number:” + printer.getItemNumber());
Desktop \ Inventory Program \ InventoryPart1.java:95:找不到符号
符号:可变的打印机,请在此处输入代码。
位置:类InventoryPart1
System.out.println(“产品名称:” + printer.getProductName());
到目前为止的代码是
导入java.text.NumberFormat;
导入java.util.locale;
导入java.util.Scanner;
类打印机{
私有字符串itemNumber;
私有字符串productName;
私人双人间
私人双人单价;
私人双单位合计;
//构造函数
公共打印机(字符串itemNumber,字符串productName,双精度单位,双精度总计){
setItemNumber(itemNumber);
setProductName(productName);
setUnits(单位);
setUnitPrice(unitPrice);
unitsTotal =单位++;
}
//类变量的访问器方法
公共字符串getItemNumber(){
返回itemNumber;
}
public void setItemNumber(字符串itemNumber){
this.itemNumber = itemNumber;
}
公共字符串getProductName(){
返回productName;
}
public void setProductName(字符串productName){
this.productName = productName;
}
public double getUnits(){
返回单位;
}
public void setUnits(双精度单位){
this.units =单位;
}
public double getUnitPrice(){
返回单价; … 是否有有方法的数学库getMean(),getMedian(),getMode(),和getRange()?