用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 ......
java 集合框架(Collection)和数组的排序
根据约定,在使用java编程的时候应尽可能的使用现有的类库,当然你也可以自己编写一个排序的方法,或者框架,但是有几个人能写得比JDK里的还要好呢?使用现有的类的另一个好处是代码易于阅读和维护,这篇文章主要讲的是如何使用现有的类库对数组和各种Collection容器进 ......
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 ......
第一次发,选个难度适当中的:我刚毕业时参加的一次笔试.
题:对任意输入入的一个字符串,把数字从小到大排列,字母逆序排列,并且输入后字母与数据交替排列。
如:"5s3fa72cs4z134556sdd"执行后为"z1s2s3s3f4d4d5c5a56".
大家可以试一下,共同学习吗?下面是我当场做的,想到哪写到哪,算法肯定不优,仅供参考.
import java.util ......