用java实现cache
在开发项目工程时,经常会遇到保存某些值放到系统的cache中,现用Cache.java和CacheManager.java来管理。具体代码分别如下:
public class Cache {
private String key;
private Object value;
private long timeOut;
private boolean expired;
public Cache() {
super();
}
public Cache(String key, String
value, long timeOut, boolean expired) {
this.key = key;
this.value = value;
this.timeOut = timeOut;
this.expired = expired;
}
public String getKey() {
return key;
}
public long getTimeOut() {
return timeOut;
}
public
Object getValue() {
return value;
 
相关文档:
原题如下:用1、2、2、3、4、5这六个数字,用java写一个程序,打印出所有不同的排列,如:512234、412345等,要求:"4"不能在第三位,"3"与"5"不能相连。
解题思路:
很明显,这是一个递归算法。我们可以排列将这6个数按从小到大的顺序排一下,如果是1,2,3,4,5,6,那么会有1 ......
import java.io.*;
public class IoTest
{
public static void main(String[] args)
{
String s;
s=calculate();
System.out.println(s);
}
static String calculate()
{
StringBuffer sb=new StringBuffer("");
try{
FileReader re ......
SQL注入是最常见的攻击方式之一,它不是利用操作系统或其它系统的漏洞来实现攻击的,而是程序员因为没有做好判断,被不法
用户钻了SQL的空子,下面我们先来看下什么是SQL注入:
比如在一个登陆界面,要求用户输入用户名和密码:
& ......
***此题以考察基础为准,北京的笔试题,可能有人做过
题:写一个程序,解析如下格式的字符串,并将解析的数字序列打印出来。
字符串格式举例: -1~2, 3~3, 5~10, 7~15x3
~ 代表数字的范围, -1~2 代表从-1开始到2之间的所有数字。 3~3 代表从3开始到3的所有数字,也就是3
7~15x3代 ......
public class Test {
public static void main(String args[]) {
System.out.println(Integer.toBinaryString(20)); //十进制-->2进制
System ......