冒泡排序和日期代码

来源:互联网 发布:人工智能的发展方向 编辑:程序博客网 时间:2024/06/11 12:18

package test;

import java.util.Calendar;
import java.util.Date;

public class TestMain {
public static void main(String[] args) {

/**
* 冒泡排序
*/
/*
* int[] array = { 5, 7, 92, 3, 4, 8 }; int temp = 0; for (int i = 0; i
* < array.length; i++) { for (int j = 0; j < array.length-1-i; j++) {
* if (array[j] > array[j+1]) { temp = array[j]; array[j] = array[j+1];
* array[j+1] = temp; } } } for (int i = 0; i < array.length; i++) {
* System.out.print(array[i]+"\t"); }
*/

/*字符串倒叙排列
* String name="曹梦琪"; StringBuffer sb = new StringBuffer(name);
* sb.reverse(); System.out.println(sb);
*/

// Long L=Timestamp.valueOf("2010-6-19 12:34:10").getTime();
// System.out.println(System.currentTimeMillis());

/**
* 获得毫秒数
*/
/*Date date = new Date();
long l = date.getTime();
System.out.println(l);*/
/**
* 当月最大天
*/
Calendar a=Calendar.getInstance();
a.set(Calendar.DATE, 1);//把日期设置为当月第一天
a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天
int MaxDate=a.get(Calendar.DATE);
System.out.println("该月最大天数:"+MaxDate);
}
}