我有一个字符串
String A;
Run Code Online (Sandbox Code Playgroud)
和一些处理它的方法
public void setA(String A) throws AInvalidException{
if(isAValid())
this.A = A;
throw new AInvalidException();
}
public boolean isAValid(){
int aLength = getA().length();
return b = (aLength==9) ? true: false;
}
public String getA(){
return A;
}
Run Code Online (Sandbox Code Playgroud)
当我试图在主要部分看到我的弦长
AClass.setA("123456789");
Run Code Online (Sandbox Code Playgroud)
它说我的String无效,调试后我看到我的String长度为零.我可能做错了什么?
我有一个JTable,每次我选择一个单元格,我想打印它的行和列索引.因此我使用getSelectedRow()和getSelectedColumn()方法.运行以下代码:
public class TestTimeTable extends JFrame{
private final int rows = 10;
private final int cols = 8;
private final String daysOfTheWeek[] = {"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"};
private final JPanel jTablePanel;
private final JScrollPane scrollPane;
private final JTable timeTable;
private final Object[][] rowData;
public TestTimeTable(){
this.rowData = new Object[this.rows][this.cols];
this.timeTable = new JTable(this.rowData,this.daysOfTheWeek){
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
this.timeTable.setRowHeight(200, 200);
this.timeTable.setFillsViewportHeight(true);
this.timeTable.setOpaque(true);
this.timeTable.setColumnSelectionAllowed(true);
this.timeTable.setRowSelectionAllowed(true);
this.timeTable.setCellSelectionEnabled(true); …Run Code Online (Sandbox Code Playgroud) 假设我们有这本字典:
thisdict = {
"brand": ["Ford","Renault", "Nissan"],
"Ford": ["red", "blue", "green"]
}
Run Code Online (Sandbox Code Playgroud)
当我将“Ford”键值更改为“droF”时,我希望它也在品牌列表中更改,反之亦然,如下所示:
thisdict = {
"brand": ["droF","Renault", "Nissan"],
"droF": ["red", "blue", "green"]
}
Run Code Online (Sandbox Code Playgroud)
有什么办法吗?