我在网上找不到任何关于此的参考资料.但只是想知道一个类中的最终字段是否应该总是static或者只是一个约定.基于我对它们的用途的理解,我觉得做的事情比语言强加的更合乎逻辑.
我想知道为什么javadoc不支持inheritedDoc是有正当理由的constructors.假设我有
class A
{
/**
* Constructor of A
*/
A(){}
/**
* Does something
*/
public void method(){}
}
class B extends A
{
/**
* {@inheritDoc}
*/
B(){ super();}
/**
* {@inheritDoc}
*/
public void method(){}
}
Run Code Online (Sandbox Code Playgroud)
对于该方法method,我可以继承javadoc,但为什么同样不能应用constructors?除非我使用inheritDoc标记,否则javadoc不会继承,这意味着我很清楚我想重用文档.什么应该阻止我这样做constructors?
在Java中,我可以编译
Object[] obj = {new Object[1], new Object[2]};
Run Code Online (Sandbox Code Playgroud)
但我无法编译
Object obj = {new Object(), new Object()};
Run Code Online (Sandbox Code Playgroud)
在第一个例子中,我声明one-dimensional array的Objects,并为它分配一个two-dimensional array.在第二个我宣布一个Object并为其分配一维数组.
如果Java数组扩展Object,为什么第二个代码片段不能编译?为什么第一个?
当我尝试创建如下对象时:
Map<Integer, Map<String, Integer>> myMap = new HashMap<Integer, HashMap<String, Integer>>();
Run Code Online (Sandbox Code Playgroud)
语法上有什么问题,任何人都可以解释一下吗?
任何人都可以粘贴简单的步骤,将Spring安全性和CAS集成到此处进行单点登录和单点注销.注意我不想要任何基于角色的访问.我有一个已经与spring security集成的Web应用程序.现在我试图用CAS执行SSO,但是我收到了这个错误 sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
这是我目前的spring security.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
">
<sec:http entry-point-ref="casProcessingFilterEntryPoint" >
<sec:intercept-url pattern="/**" access="ROLE_USER" />
<sec:logout logout-success-url="/loggedout.jsp" invalidate-session="true"/>
<sec:custom-filter ref="casAuthenticationFilter" after="CAS_FILTER"/>
</sec:http>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider ref="casAuthenticationProvider"/>
</sec:authentication-manager>
<bean id="casAuthenticationFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="authenticationFailureHandler">
<bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/casfailed.jsp"/>
</bean>
</property>
<property name="authenticationSuccessHandler">
<bean …Run Code Online (Sandbox Code Playgroud) 可以任何机构向我解释输出中发生的事情.如果==用于比较两个ref.变量它只是检查它的引用是否相同然后输入if body,那么为什么地狱aa == bb是相等的如果creting静态方法valueOf()和ee == ff不相等(这是好的)如果创建它使用新关键字的对象?
static void main(String args[])
{
Integer aa = Integer.valueOf("12");
Integer bb = Integer.valueOf("12");
if(aa==bb)System.out.println("aa==bb");
if(aa!=bb)System.out.println("aa!=bb");
Integer ee = new Integer("12");
Integer ff = new Integer("12");
if(ee==ff)System.out.println("ee==ff");
if(ee!=ff)System.out.println("ee!=ff");
}
Run Code Online (Sandbox Code Playgroud)
输出:
AA BB ==
ee值!= FF
我有一个类,我希望只能为其子对象访问该方法,而不是该包中的其他类.
Modifier | Class | Package | Subclass | World
————————————+———————+—————————+——————————+———————
public | ? | ? | ? | ?
————————————+———————+—————————+——————————+———————
protected | ? | ? | ? | ?
————————————+———————+—————————+——————————+———————
no modifier | ? | ? | ? | ?
————————————+———————+—————————+——————————+———————
private | ? | ? | ? | ?
____________+_______+_________+__________+_______
my Modifier | ? | ? | ? | ?
____________+_______+_________+__________+_______
Run Code Online (Sandbox Code Playgroud)
是否有一种解决方法来拥有这种修饰符?
也许有办法让一个包最终,所以其他程序员不能在我的包中添加任何类?
或者有没有办法获取调用该函数的实例,并检查这个是否是我的super对象的实例?
或者我只需要离开它,只使用受保护的,其他程序员可能会在我的包中添加类...
我想写这样的代码 -
for (Map.Entry<Long, Integer> e : map.entrySet()){
map.remove(k);
map.put(x, value);
}
Run Code Online (Sandbox Code Playgroud)
但我得到了java.util.ConcurrentModificationException
我也尝试使用,Iterator但我也一样Exception
我有2个AsyncTask,一个用于创建套接字连接,另一个用于使用这些套接字传输对象.我的代码是这样的:
try {
connectat = true;
transmitter = new SocketTransmitter();
transmitter.execute();
connector = new socketConnector();
connector.execute(owner);
this.open();
} catch (IOException e) {
Run Code Online (Sandbox Code Playgroud)
但是,从不创建或执行被AsyncTask调用socketConnector.我试图改变顺序但是然后没有创建或执行发射器......
那有什么不对吗?
我们不能创建构造函数synchronized但可以synchronized在构造函数中编写它.在什么情况下这样的要求会来?我很开心.
package com.simple;
public class Test {
public Test() {
synchronized (this) {
System.out.println("I am called ...");
}
}
public static void main(String[] args) {
Test test=new Test();
System.out.println(""+test);
}
@Override
public String toString() {
return "Test []";
}
}
Run Code Online (Sandbox Code Playgroud)