java基础
yangliu4683
这个作者很懒,什么都没留下…
展开
-
冒泡排序
public static void main(String []args){ int []scores = {67,89,100,32,56,43,77}; for (int i=1;i for (int j=0;j if(scores[i] int temp = scores[i]; scores[i]=scores[j]; scores[j]=temp; } } for原创 2017-10-25 17:07:48 · 195 阅读 · 0 评论 -
时间戳 String Date
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式Date date = new Date();//获取系统当前时间 Sat Feb 10 13:40:03 CST 2018long time = date.getTime();//date 转时间戳(long 1518235421189)long...原创 2018-02-10 14:59:44 · 196 阅读 · 0 评论 -
递归和迭代
区别:递归循环中,遇到满足终止条件的情况时逐层返回来结束。迭代则使用计数器结束循环。 递归:自己调用自己 举例:爬楼梯:每次选择走1步或者2步 共多少走法 public static int climbStairs(int n) { int i = 1; if(n<=0) { return 0; } ...原创 2018-04-03 13:39:43 · 157 阅读 · 0 评论 -
Long型比较
在判断两个Long型数据是否相等的时候遇到了一个问题。 if(sku.getId()==admin.getId()){returntrue;}else{returnfalse;}两个Long型的ID之间的比较,结果却是false。Longid1=123L;Longid2=123L;System.out.println(id1==id2);输出:true 源代码: private sta...转载 2018-09-30 09:42:34 · 6147 阅读 · 0 评论