- 博客(14)
- 收藏
- 关注
原创 冒泡排序-Java版
for (int i = 0; i < arr.length - 1; i++) { for (int j = 0; j < arr.length - 1 - i; j++) { if (arr[j] > arry[j + 1]) { int temp = arr[j]; ...
2019-06-24 21:51:23 113
原创 Instanceof
public class InstanceofTest { public static void main(String[] args) { Person p=new Chinese(); System.out.println(p instanceof Person);//true System.out.println(p insta...
2018-07-30 12:09:01 119
原创 多态中成员的特点
public class DuoTaiDemo1 { public static void main(String[] args) { /*多态中静态成员函数的特点:无论编译还是运行,都参考左边引用型变量所属的类 Fu f=new Zi(); f.method4();//fu method_4,只要类一加载,静态函数就存在了,而且静态...
2018-07-28 13:43:54 285
原创 生成API文档
/** 定义一个工具类,可以对数组进行寻找最大最小值和排序运算。 @author 小庞 @version 1.1 */ public class ArrayTools { /** 获取数组里最大值的方法 @param arr 传入一个整型数组 @return 返回一个int类型的数 */ public static int getMax(int[] ...
2018-07-20 20:29:42 124
原创 Static的注意事项与应用
public class StaticDemo { public static void main(String[] args) { Person p=new Person("狗剩"); p.show(); } } class Person { String name; //每一个对象都有国籍,如果定义为实例变量的话每个对...
2018-07-20 09:56:23 125
原创 this关键字在构造函数间的调用
public class ThisDemoTwo { public static void main(String[] args) { System.out.println("Hello World!"); } } //构造函数间的调用要使用关键字this(无参,参数1,参数2...) class Person { private int age;...
2018-07-20 09:10:47 1187
原创 this应用
public class ThisDemo { public static void main(String[] args) { Person p=new Person(20); Person p1=new Person(20); boolean b=p.compare(p1); System.out.println(...
2018-07-19 20:34:10 174
原创 构造函数与构造代码块
public class TestDemo { public static void main(String[] args) { Person p1=new Person(0); System.out.println(p1.getAge()+"岁"); Person p2=new Person(1); System.o...
2018-07-19 10:49:51 143
原创 set方法和构造函数
public class TestDemo { public static void main(String[] args) { Test t=new Test(-1); System.out.println(t.getAge());//-1,setAge()内的条件对构造函数初始化无影响,因为new一个对象后紧跟着执行构造函数 ...
2018-07-18 19:29:08 1703
原创 选择排序
public class TestTwo{ public static void main(String[] args) { //2.对11个数(10到100以内)进行排序(要求使用选择排序算法) //原理:每次循环从数组中选择出一个最小或者最大的元素,按顺序重新放入数组中,直到所有的排序元素都排序完成 int[] a={77,54,91,3...
2018-07-13 16:11:48 104
原创 打印等腰三角形
/*----*---* *--* * *-* * * ** * * * **//*class Day03111{ public static void main (String[] args) { //控制行数 for(int x=0;x<5;x++) { //打印“—” for(int y=x...
2018-07-13 11:27:02 167
原创 输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
import java.util.Scanner;public class TestOne { public static void main(String[] args) { /* 1. 题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 */ Scanner sc=new Scanner(System.i...
2018-07-13 10:11:53 6074
原创 对数组进行排序
public class PaiXu { public static void main(String[] args) { //初始化一个数组 int[] a={5,6,9,8,2,1,4}; //取a[i] for(int i=0;i<a.length-1;i++) { //每次由一...
2018-07-12 20:06:10 264
原创 输入三角形行数,打印空心三角形
import java.util.Scanner;public class AngleOne { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入三角形的行数:"); int line=sc.n...
2018-07-12 19:55:59 1581
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人