随笔分类 -  JAVA攻城狮

先定个小目标,3K码农。
Encapsulation、Inheritance、Polymorphism
摘要:public class SoldierDemo { public static void main(String[] args) { /*Soldier test1=new Army("张三"); test1.action(); Soldier test2=new Navy("李四"); test 阅读全文
posted @ 2016-11-25 16:18 Heavy_dream 阅读(271) 评论(0) 推荐(0)
三大基础排序算法BubbleSort、SelectSort、InsertSort
摘要:public class Strategy { public static void main(String[] args) { int [] array=new int[]{26,25,15,42,36,16,12}; IInfo test1=new BubbleSort(); //接口引用指向实 阅读全文
posted @ 2016-11-24 20:33 Heavy_dream 阅读(1380) 评论(0) 推荐(0)
计算两点坐标距离与中点坐标
摘要:/*回顾一下数学公式: 两点的坐标是(x1, y1)和(x2, y2) 则两点之间的距离公式为 d=√[(x1-x2)²+(y1-y2)²] 注意特例: 当x1=x2时 两点间距离为|y1-y2| 当y1=y2时 两点间距离为|x1-x2| 中点坐标:midpoint(X,Y) X=(X1+X2)/ 阅读全文
posted @ 2016-11-23 17:24 Heavy_dream 阅读(6531) 评论(0) 推荐(0)
欧几里得算法之最大公约数与最小公倍数
摘要://求最大公约数public class Parent { public int f(int a,int b){ if(a<b){//辗转相除是用大的除以小的。如果a<b,第一次相当a与b值交换 int temp=a; a=b; b=temp; } while(a%b!=0){ int temp=a 阅读全文
posted @ 2016-11-23 14:55 Heavy_dream 阅读(1113) 评论(0) 推荐(0)
小JAVA大世界之程序建模跳蚤实验
摘要:package com.chigoe;//房子类class House { private int m;// 保存行数 private int n;// 保存列数 private int[][] a; public House() { // 无参构造方法 m = 10; n = 10; for (i 阅读全文
posted @ 2016-10-30 18:35 Heavy_dream 阅读(373) 评论(0) 推荐(0)
小JAVA大世界之万年历
摘要:import java.util.Scanner; public class Calendar { public static void main(String[] args) { // 万年历 int year;// 保存输入的年 int month;// 保存输入的月 System.out.pr 阅读全文
posted @ 2016-10-30 16:03 Heavy_dream 阅读(290) 评论(0) 推荐(0)