开发者

Java doubt on unique date issue

In a loop, I am to create a new object only if the date is different than the previousl开发者_如何学运维y iterated value. Otherwise i want the same object. Can anyone help?


Your questions lacks a lot of information so I can't give you code you can use with out changes. Here is the general code that you seem to be asking for. You will need to fill in the comments with code that matches what you were asking for.

curDate = null;
lastDate = null;
for(/*loop statement*/){
    lastDate = curDate;
    curDate = /*get next date from iterator*/;
    if(lastDate == null){
        continue;
    }
    if(lastDate.compareTo(curDate) == 0){
        /*the same object*/
    }else{
        /*create a new object*/
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜