我正在创建一个INSERT脚本,我遇到了一个问题.有一个中间的初始字段是char(1)
有时记录在该字段中没有任何内容,所以我放了一个NULL.这会导致数据太长而不会出现列错误.我不想只是把''留下空白.
还有另一种方法吗?
我是wicket的新手,当我尝试运行我的应用程序时,他遇到错误:
WicketMessage:模态窗口内容id错误.组件ID:myPanel; 内容ID:内容:
在我的AddStudent html中:
<span wicket:id="InformationDialog"/>
<span wicket:id="myPanel"/>
Run Code Online (Sandbox Code Playgroud)
这是我打开标签后的第一件事
在AddStudent.java中(在构造函数中):
panel=new InformationPanel("myPanel");
message=new ModalWindow("InformationDialog");
message.setContent(panel);
message.setCssClassName(ModalWindow.CSS_CLASS_BLUE);
message.setTitle("Important Information");
Run Code Online (Sandbox Code Playgroud)
InformationPanel扩展Panel的位置:
<html>
<wicket:panel>
<table>
<tr>
<td><span wicket:id="message"/></td>
</tr>
<tr>
<td><input type ="button" value ="OK" wicket:id="ok"/></td>
</tr>
</table>
</wicket:panel>
<html>
Run Code Online (Sandbox Code Playgroud)
显然,我有一个相应的java类 - 它可能没有关系,但在这里它是:
package myapp.project;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.panel.Panel;
public class InformationPanel extends Panel {
private Button ok;
private Label messageLabel;
public InformationPanel(String id){
super(id);
messageLabel=new Label("message","");
ok=new Button("ok"){
public void onSubmit(){
AddStudent student = new AddStudent();
setResponsePage(student);
}
}; …Run Code Online (Sandbox Code Playgroud) 我需要计算我的数据集的单个单位的变量之间的平均值.但是,在这样做的时候,我需要不考虑一些价值观.为了更好地解释,想想有两个单元和三个变量:
V1 V2 V3
[1] 3 -2 4
[2] -1 4 1
Run Code Online (Sandbox Code Playgroud)
并且您想要按行计算平均值,而不考虑这些负值:
=> mean(1row)=(3 + 4)/ 2
=> mean(2row)=(4 + 1)/ 2
有谁能请给我命令在R?
非常感谢
这是一个非常新手的问题,但我不知道如何存根.
我必须模拟一个像这样返回Class的方法.
public Class<? extends SomeClass> getAClass();
Run Code Online (Sandbox Code Playgroud)
如果我做这样的事情
when(this.someInstance.getAClass())
.thenReturn(SomeClassThatExtendsSomeClass.class);
Run Code Online (Sandbox Code Playgroud)
我收到编译错误.
The method thenReturn(Class<capture#1-of ? extends SomeClass>) in the type OngoingStubbing<Class<capture#1-of ? extends SomeClass>> is not applicable for the arguments (Class<SomeClassThatExtendsSomeClass>)
Run Code Online (Sandbox Code Playgroud) //检查数字是偶数还是奇数没有/或%运算符.
public class EvenOrOdd {
public static int CheckEvenOrOdd(int num) {
if (num > 2) {
int number = num - 2;
num = CheckEvenOrOdd(number);
}
return num;
}
public static void main(String[] args) {
int num = CheckEvenOrOdd(5322221);
if (num == 1) {
System.out.println("Odd number");
} else {
System.out.println("Even number");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我将堆栈大小定义为200m为-xss200m,但如果number大于5322221,则此程序会出现OutOfMemory错误和StackOverflow错误.
建议如何解决这个问题,找到数字是偶数还是奇数.
我编写了一个程序来在HashSet中插入数据......这里是代码
public class Person implements Comparable<Person>
{
private int person_id;
private String person_name;
public Person(int person_id,String person_name)
{
this.person_id=person_id;
this.person_name=person_name;
}
/* getter and setter method */
public boolean equals(Object obj)
{
Person p=(Person)obj;
if(!(p instanceof Person))
{
return false;
}
else if(this.person_id==p.person_id)
return true;
else
return false;
}
@Override
public int hashCode()
{
return person_id*6;
}
@Override
public int compareTo(Person o)
{
if(this.person_id>o.person_id)
return 1 ;
else if(this.person_id<o.person_id)
return -1;
else return 0;
}
}
Run Code Online (Sandbox Code Playgroud)
我还没有粘贴其他两个类.我在这些类中所做的就是填充数据而其他类是主类.
现在我明白了,通过Java Doc Api我知道在Collections类中有一个名为sort()的方法.现在我的问题就是那个排序mathod的列表. …
我有一些使用事务同步管理器的代码..但我似乎无法让它在模拟中工作..我在模拟实体管理器和事务管理器..这样我的上下文保存实体并调用提交...... TransactionSynchronizationManager 确实如此似乎没有被击中……在测试中?
this.transactionTemplate.execute(new TransactionCallback<E>() {
@Override
public E doInTransaction(TransactionStatus status) {
// update entities
TransactionSynchronizationManager.registerSynchronization(new NotificationTransactionSynchronization(){
@Override
public void afterCommit() {
// do some post commit work
int i = notifier.notifyAllListeners();
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
我的测试课:
@Test
public void testHappyPath() {
context.checking(new Expectations() {
{
allowing(platformTransactionManager).getTransaction(definition);
will((returnValue(status)));
oneOf(platformTransactionManager).commit(status);
//next line never gets hit... so the test fails...
//if i remove it will pass but i need to check that it works...
oneOf(mockNotifier).notifyAllListeners();
}
});
this.TestClass.process();
context.assertIsSatisfied();
}
Run Code Online (Sandbox Code Playgroud) 我尝试将ComboBox.SelectedItem()转换为int,但无法正常工作。我知道ComboBox.SelectedItem()的类型为String,我像这样强制转换:
int idprovider = ((Integer)IdProviderComboBox.getSelectedItem()).intValue();
Run Code Online (Sandbox Code Playgroud)
但我收到错误:java.lang.ClassCastException:java.lang.String无法转换为java.lang.Integer
也许有人有一个主意。谢谢!
结果集关闭时语句会发生什么?
Statement stmt = null;
ResultSet rs = null;
try {
stmt = con.createStatement();
rs = stmt.executeQuery(query.toString());
...
}
// lots of code
rs.close()
Run Code Online (Sandbox Code Playgroud)
注意:当Statement对象关闭,重新执行或用于从多个结果序列中检索下一个结果时,Statement对象会自动关闭该对象.
但是当ResultSet首先关闭时会发生什么?
对于什么问题,首先应该发生什么?
我的教授为我提供了一系列方法来填写罗马数字程序(加法格式,所以4 = IIII,9 = VIIII等)
我无法理解这两种方法之间的区别:
**
* This method prints, to the standard output and in purely additive
* notation, the Roman numeral corresponding to a natural number.
* If the input value is 0, nothing is printed. This
* method must call the method romanDigitChar().
* @param val ?
*/
public void printRomanNumeral(int val)
{
}
**
* This method returns the Roman numeral digit corresponding
* to an integer value. You must use a nested-if statement.
* …Run Code Online (Sandbox Code Playgroud)