我有这个代码.为什么它不起作用?(工作意味着它显示3)我该如何解决?
public class Main {
public static<V> V copy(V var){
try{
return (V) var.getClass().getConstructor(var.getClass()).newInstance(var);
}
catch(Exception e){
System.out.println("Copy faield " + e.getMessage() + " ");
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
Integer a = new Integer(3);
Integer b = copy(a);
System.out.println(a);
System.out.println(b);
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
Copy faield java.lang.Integer.<init>(java.lang.Integer)
java.lang.NoSuchMethodException: java.lang.Integer.<init>(java.lang.Integer)
at java.lang.Class.getConstructor0(Class.java:2818)
at java.lang.Class.getConstructor(Class.java:1723)
at Main.copy(Main.java:7)
at Main.main(Main.java:19)
3
null
Run Code Online (Sandbox Code Playgroud)
谢谢!
我想更改QFrame组件的边框颜色.也尝试使用样式表但在运行时没有效果.在我的项目中有各种各样的Dialog UI,基本上是QFrame,我想改变所选对话框的边框颜色,即QFrame边框颜色.在QT中是否有任何解决方法.如下所示,当选择它的相应帧边框颜色中的任何一个应该被改变时,有两个对话框
