我有一个函数,其参数是:
myFn(String, List<Number>, List<Number>)
Run Code Online (Sandbox Code Playgroud)
调用函数有两个List对象,我想用它作为函数的第二个和第三个参数.我收到编译错误:
The method myFn(String, List<Number>, List<Number>) in the type MyLib is not applicable for the arguments (String, List<Double>, List<Double>)
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法来克服这个问题?有没有一种简单的方法可以将Double列表转换为Number of List?
我在JodaTime的Period课程中遇到了一个奇怪的问题.我已经实现了一个Period对象,它被打印为:PT8M19.966S,清楚地说8分19秒(此时这是正确的),我调用Period.toMillis.我得到的结果是一些随机数,例如968或152,这些数字显然不是这个方法应该返回的数字.所以我想知道它是否是某种错误,或者是我身边的误用.
我有点卡住了.当我按下按钮时,提交应该重新显示JLabel图像在同一位置的另一张图片,所以如果有人有任何想法我会很感激他们我正在使用eclipse并且该程序正在编译和运行.这是代码
/** Here is the GUI of the program
* class name SlideShowGui.java
* @author Kiril Anastasov
* @date 07/03/2012
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class SlideShowGui extends JPanel implements ActionListener
{
JLabel name, comments, images;
JTextField namejtf, commentsjtf, captionjtf;
JButton submit;
ImageIcon pictures;
SlideShowGui()
{
name = new JLabel("Name:");
this.add(name);
namejtf = new JTextField(15);
this.add(namejtf);
comments = new JLabel("Comments:");
this.add(comments);
commentsjtf = new JTextField(15);
this.add(commentsjtf);
submit = new JButton("Submit");
this.add(submit);
submit.addActionListener(this);
pictures = new …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在循环中创建点模式列表ppp.object {spatstat}.我的数据集如下所示:
> names(OT1);head(OT1);dim(OT1)
[1] "EID" "latitude" "longitude" "month" "year" "CPUE" "TSUM"
[8] "fTSUM"
EID latitude longitude month year CPUE TSUM fTSUM
1 167-1-1996-1135 67.70000 -61.81667 9 1996 0 0 F
2 167-10-1996-1135 67.71667 -59.18333 9 1996 0 0 F
3 167-100-1996-1135 67.86667 -59.43333 10 1996 0 0 F
4 167-101-1996-1135 67.95000 -59.58333 10 1996 0 0 F
5 167-102-1996-1135 68.10000 -59.76667 10 1996 0 0 F
6 167-103-1996-1135 67.81667 -59.38333 10 1996 0 0 F
[1] 2707 8
Run Code Online (Sandbox Code Playgroud)
我想做的是为我的每个月选择数据并创建一个ppp.object. …
我只是在研究Builder模式,并不理解Director的观点.
http://en.wikipedia.org/wiki/Builder_pattern
不只是让Builder和他们的子类足够吗?
谢谢
我有一个HandlerInterceptor来添加一些"全局"模型变量.有用.
现在,出于同样的原因,我尝试在Spring Web Flow中重用它.
但 HandlerInterceptors在Spring Web Flow下将ModelAndView参数设置为NULL(无法解释原因,但这是事实).
我在FlowHandlerMapping bean中引用了我的拦截器:
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="order" value="0" />
<property name="flowRegistry" ref="flowRegistry" />
<property name="interceptors">
<list>
<ref bean="myInterceptor" />
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
如何将变量添加到模型中?
有一个解决方法,例如请求参数?
我正在查看淘汰教程,所有示例都使用'new'关键字创建视图模型:
//from learn.knockoutjs.com
function AppViewModel() {
this.firstName = ko.observable("Bert");
this.lastName = ko.observable("Bertington");
this.fullName = ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this);
}
ko.applyBindings(new AppViewModel());
Run Code Online (Sandbox Code Playgroud)
我试图避免使用new关键字,这通常可以正常工作,但我发现使fullName computed属性工作有困难.这是我到目前为止所提出的.
function makeViewModel() {
return {
firstName: ko.observable("Bert"),
lastName: ko.observable("Bertington"),
fullName: ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this) };
}
ko.applyBindings(makeViewModel());
Run Code Online (Sandbox Code Playgroud)
...显然失败,因为'this'不再引用传递给compute的函数内的局部对象.我可以通过创建变量并在附加计算函数并返回它之前存储视图模型来解决这个问题,但是如果存在更优雅和紧凑的解决方案,则不需要我确保相互依赖的方法是按照正确的顺序附上,我肯定想用它来代替.
有更好的解决方案吗?
以这两个类为例:
struct Owned {
Owned() : i() { }
void print() { cout << ++i << endl; }
int i;
};
struct Owner {
Owner(Owned& o) : o(o) { }
Owned& o;
~Owner() { o.print(); }
};
Run Code Online (Sandbox Code Playgroud)
以这种方式使用它们是危险的吗?
int main() {
Owned owned;
Owner owner(owned);
}
Run Code Online (Sandbox Code Playgroud)
似乎,根据它们被破坏的顺序,这可能导致析构owner
函数在被破坏的函数上调用函数owned
.是否定义了局部变量的破坏顺序,以及如何使两个实例相互引用的情况?
请原谅我,如果这是常识,我在任何地方都没有读过任何关于它的信息.
我发现了越来越多关于Java 8的新闻 - 然而,Java 7刚刚被许多地方采用.例如,在我的工作中,我们仍然使用Java 6,即使我们中的一些人拥有Java 7.
我想知道 - Java可用版本的限制是什么?我们多久可以期望推出和实施新的Java规范.我一直认为Java 8将来会很遥远,因为Java 7仍在不断发展.
也许有一个很好的(非tl; dr)官方消息来源我缺少这些细节,如果有的话,请告诉我.
我的应用程序使用Spring 3.0.4(这是第一个版本,其中标签mvc:资源正常工作).当前的问题是我的应用无法从映射的资源中访问.css和.js文件.
结构test.war:
/test -root
|
/static-resource
|
/css
|
/screen.css
|
/js
|
/WEB-INF
|
/index.jsp
Run Code Online (Sandbox Code Playgroud)
我的test-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/static-resource/"/>
<context:annotation-config/>
<context:component-scan base-package="org.web"/>
<tx:annotation-driven/>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles-defs.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="authenticationInterceptor" class="org.util.AuthenticationInterceptor"/>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages"/> …
Run Code Online (Sandbox Code Playgroud) java ×4
spring-mvc ×2
c++ ×1
casting ×1
destructor ×1
generics ×1
java-7 ×1
java-8 ×1
javascript ×1
jodatime ×1
knockout.js ×1
loops ×1
period ×1
r ×1
reference ×1
resources ×1
swing ×1
tags ×1
viewmodel ×1