ArrayList实现RandomAccess接口.RandomAccess接口没有方法.当我检查LinkedList它没有实现RandomAccess接口.
那么在哪种情况下ArrayList,实施它有什么意义呢?
我想在这里澄清的第一件事,这个问题是因为好奇心.我没有遇到任何问题.
在Java中获得许多原始类型byte,short,int,等现在假设我要创建一个新的基本类型(例如,mediumint或其他任何东西).我们可以这样做吗?如果是,那怎么样?
Java有3个类加载器:
他们有一个角色; 从不同的包加载类.
但是为什么Java有3个不同的类加载器而不是只有一个,因为一个类加载器可以加载所有必需的类?
我试图在我的春季Web应用程序中集成Spring Security.基本上我需要根据用户权限隐藏一些菜单.这就是我做的.
我在classpath中添加了JARS.
spring-security-acl-4.0.2.RELEASE.jar
spring-security-config-4.0.2.RELEASE.jar
spring-security-core-4.0.2.RELEASE.jar
spring-security-taglibs-4.0.1.RELEASE.jar
spring-security-web-4.0.2.RELEASE.jar
Run Code Online (Sandbox Code Playgroud)
以下是web.xml中的条目
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>/WEB-INF/web_log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-root.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Run Code Online (Sandbox Code Playgroud)
我写了一个类CustomPermissionEvaluator,如下所示.
public class CustomPermissionEvaluator implements PermissionEvaluator{
@Override
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
HttpServletRequest request = (HttpServletRequest) targetDomainObject;
Profile userProfile = (Profile) request.getSession().getAttribute("testprofile");
if (userProfile.getPermissionMap().get(String.valueOf(permission)) != null) {
return true;
} else {
return false;
}
}
@Override
public boolean hasPermission(Authentication arg0, Serializable arg1,
String arg2, Object arg3) {
// TODO Auto-generated …Run Code Online (Sandbox Code Playgroud) 我有一个Web应用程序,我在其中使用java.util.logging.在我的logging.properties文件中,默认级别是info.我的应用程序中有记录器用于所有级别的日志记录(信息,调试,致命等).此Web应用程序将部署在WebSphere 8上.
如果我想在运行时通过WAS管理控制台更改日志记录级别,从信息到错误,应用程序怎么办?我怎样才能做到这一点?
我有一个简单的下面的程序,它遍历一个数组
Integer [] intArray = new Integer[20000];
int index=0;
for(int i=10000; i>=0; i--){
intArray[index]=i;
index++;
}
long startTime = System.currentTimeMillis();
for(Integer t : intArray){
System.out.println(t);
}
long endTime = System.currentTimeMillis();
long consumedTime = endTime-startTime;
System.out.println("Consumed time "+ consumedTime);
Run Code Online (Sandbox Code Playgroud)
我总是得到不同的消耗时间值,如743,790,738,825,678.
为什么for循环所花费的时间对于每次执行总是不同的.
注意我在main方法中运行此代码.我的操作系统是Ubuntu,处理器是32位.
我有一个表有2列empid和depid.此表没有任何主键.以下是该表的数据.
+-------+-------+
| empid | depid |
+-------+-------+
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 2 | 1 |
| 2 | 2 |
| 2 | 3 |
| 2 | 4 |
+-------+-------+
Run Code Online (Sandbox Code Playgroud)
现在选择我在下面查询的员工的所有depids.
select empid, group_concat(depid separator ':') from emp group by empid;
Run Code Online (Sandbox Code Playgroud)
它给了我预期的输出.
+-------+-----------------------------------+
| empid | group_concat(depid separator ':') |
+-------+-----------------------------------+
| 1 | 1:2:3:4 |
| 2 | 1:2:3:4 | …Run Code Online (Sandbox Code Playgroud) 根据javadoc通知唤醒正在此对象监视器上等待的单个线程.如果任何线程正在等待此对象,则选择其中一个线程被唤醒.选择是任意的,由实施决定.线程通过调用其中一个wait方法等待对象的监视器.
我想知道notify如何实现这种行为.在我读过的很多网站上发送信号但信号在这里意味着什么?
notify是否直接向第一个等待线程发送信号,或者它向线程调度程序发送信号?
我最近开始探索Java Executor框架.所有执行程序都设计为接受Runnable或Callable.为什么执行者不接受Thread作为输入?
java ×8
classloader ×1
collections ×1
concurrency ×1
java-threads ×1
logging ×1
mysql ×1
spring ×1
spring-mvc ×1
types ×1
websphere ×1