随笔分类 -  JAVA基础

摘要:代码如下: package four.day8.com; public class Person { private String name;; private int age; public Person() { super(); } public Person(String name,int a 阅读全文
posted @ 2016-08-08 15:35 caocx 阅读(274) 评论(0) 推荐(0)
摘要:代码如下 Student.java package four.com; public class Student extends Person { // private String name; // private int age; public Student(){} public Studen 阅读全文
posted @ 2016-08-03 13:59 caocx 阅读(188) 评论(0) 推荐(0)
摘要:代码如下: package cao.com.duixiang; public class TestCCircle { public static void main(String[] args) { PassObjectt op = new PassObjectt(); CircleC cc = n 阅读全文
posted @ 2016-07-28 16:03 caocx 阅读(236) 评论(0) 推荐(0)
摘要:两个类如下 package cao.com.duixiang; import java.util.Arrays; public class OtherTest { //求max public int getMax(int[] arr) { int max = arr[0]; for(int i=1; 阅读全文
posted @ 2016-07-28 14:30 caocx 阅读(407) 评论(0) 推荐(0)
摘要:注:选择排序就是从第一个数开始依次遍历,找出最小的数,然后交换位置,直到剩余元素只有一个为止。 代码如下: public class MaoPao { public static void main(String[] args){ //直接选择排序 int[] arr = new int[]{49, 阅读全文
posted @ 2016-07-27 20:37 caocx 阅读(208) 评论(0) 推荐(0)
摘要:public class MaoPao { public static void main(String[] args){ int[] arr = new int[]{49,38,65,76,13,27,49}; //i代表的是查询的轮数 for(int i=0;i<arr.length;i++){ 阅读全文
posted @ 2016-07-27 18:00 caocx 阅读(196) 评论(0) 推荐(0)
摘要:代码如下: public class ErArray { public static void main(String[] args) { //杨辉三角 int[][] num = new int[10][]; //初始化动态数组 for(int i=0;i<num.length;i++){ //这 阅读全文
posted @ 2016-07-27 15:10 caocx 阅读(288) 评论(0) 推荐(0)
摘要:import java.util.Scanner;public class TestStudent { public static void main(String[] args) { //从键盘获得数据 Scanner scan = new Scanner(System.in); //输入学生个数 阅读全文
posted @ 2016-07-27 11:19 caocx 阅读(2032) 评论(0) 推荐(0)
摘要:代码如下: public class TestDemo { public static void main(String[] args) { //完数的计算机。例子:6 =1+2+3 一个数等于它的各个公约数的和 int factor =0; for(int i=1;i<=1000;i++){ // 阅读全文
posted @ 2016-07-26 16:48 caocx 阅读(571) 评论(0) 推荐(0)
摘要://代码一: public class TestDemo { public static void main(String[] args) { //输出100以内的所有质数(素数,奇数),2是最小的质数 boolean flag =false; //计算时间 long star = System.c 阅读全文
posted @ 2016-07-26 16:33 caocx 阅读(549) 评论(0) 推荐(0)
摘要:代码如下: public class TestDemo { public static void main(String[] args) { //输出100以内的所有质数(素数,奇数),2是最小的质数 boolean flag =false; //计算时间开始时间 long star = Syste 阅读全文
posted @ 2016-07-26 15:51 caocx 阅读(411) 评论(0) 推荐(0)
摘要:代码如下:注,可以在原有的基础上,多加修改 public class TestJiuJiu { public static void main(String[] args) { for(int i =1;i<=9;i++){ for(int j=1;j<=i;j++){ // /t相当于table键 阅读全文
posted @ 2016-07-26 14:59 caocx 阅读(261) 评论(0) 推荐(0)
摘要:正三角形代码如下: * *** ***** *******-********* public class TestForWhile { public static void main(String[] args) { for(int i=0;i<5;i++){ for(int k=1;k<5-i;k 阅读全文
posted @ 2016-07-26 14:39 caocx 阅读(1715) 评论(0) 推荐(0)
摘要:代码如下: import java.util.Scanner;class TestForWhile { public static void main(String[] args) { //注:无限循环的条件for(;;){},while(true){} Scanner scan = new Sca 阅读全文
posted @ 2016-07-26 10:21 caocx 阅读(397) 评论(0) 推荐(0)
摘要:代码如下: import java.util.Scanner;public class TestForWhile { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int count=0 阅读全文
posted @ 2016-07-26 10:00 caocx 阅读(1606) 评论(0) 推荐(0)