如果没有收到此错误消息,我无法运行我的Java代码:
在"启动事物"期间发生内部错误.
组织/日蚀/ JDT /调试/核心/ JDIDebugModel
这是代码:
import javax.swing.JOptionPane;
class thing {
public static void main(String[] args){
String f = JOptionPane.showInputDialog("First number: ");
String s = JOptionPane.showInputDialog("Second Number: ");
int first = Integer.parseInt(f);
int second = Integer.parseInt(s);
int sum = first + second;
JOptionPane.showMessageDialog(null, "Answer: " + sum, "Title", JOptionPane.PLAIN_MESSAGE);
}
}
Run Code Online (Sandbox Code Playgroud)
错误日志:
其中包含:
eclipse.buildId=M20110909-1335
java.version=1.7.0_01
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86
This is a continuation of log file C:\Users\Cole\workspace\.metadata\.bak_0.log …Run Code Online (Sandbox Code Playgroud) 我喜欢上课
public User{
Long id;
Set<String> roles;
}
Run Code Online (Sandbox Code Playgroud)
如何查询User具有角色的所有对象"ADMIN"
编辑:
我正在使用Hibernate 3.0.5.并尝试了大多数明显的方法.
from Users where roles in('ADMIN')给出了JDBC错误.
from Users u where u.roles in('ADMIN')给出一个类强制转换异常
我认为这可能是这个特定版本的hibernate的一个问题.
在我的Android应用程序中,我正在录制用户的声音,我将其保存为.3gp编码的音频文件.
我想要做的是打开它,即表示音频样本的序列x [n],以便执行一些音频信号分析.
有谁知道我怎么能这样做?
所以我有一个接受泛型类型参数的类,如果type参数是给定类型的子类,则会进行一些特殊处理.
IEnumerable<T> models = ...
// Special handling of MySpecialModel
if (filterString != null && typeof(MySpecialModel).IsAssignableFrom(typeof(T)))
{
var filters = filterString.Split(...);
models =
from m in models.Cast<MySpecialModel>()
where (from t in m.Tags
from f in filters
where t.IndexOf(f, StringComparison.CurrentCultureIgnoreCase) >= 0
select t)
.Any()
select (T)m;
}
Run Code Online (Sandbox Code Playgroud)
但是我在最后一行得到例外
Cannot convert type 'MySpecialModel' to 'T'
Run Code Online (Sandbox Code Playgroud)
如果我更改代码as而不是强制转换,我会收到此错误.
The type parameter 'T' cannot be used with the 'as' operator because it does not have a class type constraint nor a 'class' …Run Code Online (Sandbox Code Playgroud) 我经常需要比较两个文件,而忽略这些文件中的某些更改.我不想忽略整条线,只是它们的一部分.最常见的情况是线上的时间戳,但我还需要忽略其他几十种模式.
文件1:
[2012-01-02] Some random text foo
[2012-01-02] More output here
Run Code Online (Sandbox Code Playgroud)
文件2:
[1999-01-01] Some random text bar
[1999-01-01] More output here
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我想看到第1行的差异,但不是第2行.
使用diff的-I选项不起作用,因为它忽略整行.理想输出:
--- file1 2013-04-05 13:39:46.000000000 -0500
+++ file2 2013-04-05 13:39:56.000000000 -0500
@@ -1,2 +1,2 @@
-[2012-01-02] Some random text foo
+[1999-01-01] Some random text bar
[2012-01-02] More output here
Run Code Online (Sandbox Code Playgroud)
我可以用sed预处理这些文件:
sed -e's/^\[....-..-..\]//' < file1 > file1.tmp
sed -e's/^\[....-..-..\]//' < file2 > file2.tmp
diff -u file1.tmp file2.tmp
Run Code Online (Sandbox Code Playgroud)
但后来我需要将这些临时文件放在某处,并记得事后清理它们.此外,我的diff输出不再引用原始文件名,也不再发出原始行.
是否有广泛可用的差异变体或类似工具,可以作为单个命令执行此操作?
为什么StringBuilder不会在小代码中打印它应该打印的内容
public final class Test1 {
public void test() {
System.out.println(setFin().toString());
}
protected StringBuilder setFin() {
StringBuilder builder = new StringBuilder();
try {
builder.append("John");
return builder.append("Ibrahim");
} finally {
System.out.println("In finaly"); // builder.append("-DarElBeida");
builder = null;
}
}
public static void main(String args[]){
new Test1().test();
}
}
Run Code Online (Sandbox Code Playgroud)
在执行的最后一条语句setFin()(中finally块)我已经分配null给builder,但我的代码打印"In finally",然后"JohnIbrahim".任何人都可以向我解释这里发生了什么吗?
我正在阅读JVM规范,试图找出如何正确处理监视器.他们在相关部分中给出的示例如下所示:
0 aload_1 // Push f
1 dup // Duplicate it on the stack
2 astore_2 // Store duplicate in local variable 2
3 monitorenter // Enter the monitor associated with f
4 aload_0 // Holding the monitor, pass this and...
5 invokevirtual #5 // ...call Example.doSomething()V
8 aload_2 // Push local variable 2 (f)
9 monitorexit // Exit the monitor associated with f
10 goto 18 // Complete the method normally
13 astore_3 // In case of …Run Code Online (Sandbox Code Playgroud) 如何在不使用ComponentListener或其他监听器的情况下将GlassPaane中的JLabel粘贴到JProgressBar的相对浮动坐标,
是否有标准布局管理器中的built_in通知程序可以通知其内部状态,并且可以访问覆盖,而不是我尝试使用ComponentListener和NullLayout

.

SSCCE关于ComponentListener和与NullLayout
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.UIManager;
//http://stackoverflow.com/questions/14560680/jprogressbar-low-values-will-not-be-displayed
public class ProgressSample {
private JFrame frame = new JFrame("GlassPane instead of JLayer");
private JLabel label;
private GridBagConstraints gbc = new GridBagConstraints();
private JProgressBar progressSeven;
public ProgressSample() {
frame.setLayout(new FlowLayout());
frame.add(new JButton("test"));
frame.add(new JCheckBox("test"));
frame.add(new JRadioButton("test"));
// Nothing is displayed if value is lover that 6 …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
xwork-conversion.properties
java.math.BigDecimal=demo.BigDecimalConverter
Run Code Online (Sandbox Code Playgroud)
BigDecimalConverter.java
package demo;
import java.math.BigDecimal;
import java.util.Map;
import org.apache.struts2.util.StrutsTypeConverter;
public class BigDecimalConverter extends StrutsTypeConverter{
@Override
public Object convertFromString(Map context, String[] values, Class clazz) {
System.out.println("BigDecimal : Converting from String : " + values[0]);
return new BigDecimal(values[0]);
}
@Override
public String convertToString(Map context, Object value) {
String str = ((BigDecimal)value).toPlainString();
System.out.println("BigDecimal : Converted to String : " + str);
return str;
}
}
Run Code Online (Sandbox Code Playgroud)
TheAction.java
package demo;
//imports...
public class TheAction extends ActionSupport {
private BigDecimal bigField; //with getter …Run Code Online (Sandbox Code Playgroud) 我必须用下划线分割一个字符串.字符串可能有许多下划线但我必须用最后一个下划线拆分它.如何使用正则表达式进行简单的拆分方法?