自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(62)
  • 收藏
  • 关注

原创 别名问题

基本类型的赋值不存在此问题,但在为对象的赋值时实际是将引用从一个地方复制到另一个地方;package chapter3.operators;class Integral{    float f;}public class Aliasing {    public static void main(String[] args) {        Integral n1 = new I...

2018-11-16 15:04:20 492

原创 双向链表的操作

    //基于双向链表算法的集合    //建立一个内部类保存节点    private Node first;//第一个节点对象    private Node last;//最后一个节点对象    private int size;//链表的节点对象的个数            public void remove(Object ele) {        //找到被删除的节...

2018-11-04 19:09:50 189

原创 根据线性表算法实现的ArrayList集合

package study.struct.array;import java.util.Arrays;public class MyListTable {        private Object[] elements = null;//         private int size = 0;// 个数        // 动态初始化                publ...

2018-11-04 15:04:53 173

原创 迭代与反向迭代

    public static void main(String[] args) {        List list = new ArrayList();        list.add("dsfdsfsd");        list.add("dsf");        list.add("dsfdd");        list.add("dsfdsfffdsfdsfsd")...

2018-11-03 19:21:56 621

原创 迭代器的并发修改异常

指的是在迭代的过程中集合的元素发生了改变,所以不允许在遍历过程中使用集合的方法改变的集合;     public static void main(String[] args) {        List<String> s = new ArrayList<String>();        s.add("abc");        s.add("abc1")...

2018-11-03 15:27:46 617

原创 List集合的简单使用

    public static void main(String[] args) {        List<String> list = new ArrayList<String>();        list.add("dsfs");        list.add("dsfdfgfdg");        list.add("ffgfgf");     ...

2018-11-03 15:14:16 175

原创 重写哈希集合的方法

class A {    int count;        public A() {        super();        // TODO Auto-generated constructor stub    }    public A(int count) {        this.count = count;    }    public String to...

2018-11-03 13:10:55 191

原创 HashSet的注意点

class A{    public boolean equals(Object o) {        return true;    }}class B{    public int hashCode() {        return 1;    }}class C{    public int hashCode() {        return 2;    }...

2018-11-03 11:25:35 207

原创 Stream的使用

    public static void main(String[] args) {        //使用方法调用链来添加流元素        IntStream is = IntStream.builder()//default Builder add(int t) {//                accept(t);//                return this...

2018-11-03 11:07:50 178

原创 Predicate的使用重要,多看多理解

    public static <E> int calAll(Collection<E> co,Predicate<E> pr) {        int total = 0;        for(E obj : co) {            if(pr.test(obj)) {//我在这里认为要检验的是集合从而惯性地填写了集合名co其实我要检测...

2018-11-03 09:45:08 1645

原创 关于java异常

异常是一个事件,发生在程序运行期间,干扰了正常的指令流程;java异常都是对象;在java中所有异常都有一个共同的祖先Throwable(可抛出)。它有两个子类:Exception(异常)和Error(错误);二者都是java异常处理的重要子类;错误:是程序无法处理的错误,表示运行应用程序中的较严重的问题;主要有VirtualMachineError(java虚拟机运行错误)、OutOfM...

2018-11-02 20:13:50 114

原创 异常的练习,经典

public class TestException {    //无参构造    public TestException() {}    //默认的布尔返回值的方法且抛出异常    boolean testEx()throws Exception {        boolean ret = true;//声明布尔变量        try {            //可能出现...

2018-11-02 19:40:26 215

原创 集合collection接口方法的训练

public class vc {    //接口多态的方式调用    public static void showColl() {        Collection<String> coll = new ArrayList<String>();        coll.add("ad");        coll.add("ads");        co...

2018-11-02 17:02:10 171

原创 正则的练习

    public static boolean isPhoneNumber(String num) {        if(num.matches("[1][34578][\\d]{9}"))            return true;        return false;    }            public static boolean isMathces(S...

2018-11-02 12:38:21 158

原创 在异常中jsr的一个命令

    public static int getNumber() {        //jsr java规范请求        //尝试返回x,但并未返回,需要观察finally语句的执行        //此时JVM会执行jsr指令,声明一个局部变量存储x的值当finally语句执行完了,再将该局部变量的值返回        int x = 10;        try {    ...

2018-11-02 10:13:52 210

原创 将一个数组转换成字符串

public static String toString(int[] arr) {        StringBuilder str = new StringBuilder();        str.append("[");        for (int i = 0; i < arr.length; i++) {            if (i == arr.length -...

2018-11-02 08:36:56 2049

原创 求指定字符串中另一个字符串出现的个数

public static int getCount(String str,String key) {        int count = 0;        int index = 0;        while((index = str.indexOf(key))!=-1) {            count++;            str = str.substring(i...

2018-11-01 22:43:52 413 1

原创 单例模式

public class SingleonTest {    public static void main(String[] args) {        Singleon s1 = Singleon.getInstance();        Singleon s2 = Singleon.getInstance();        System.out.println(s1==s2);...

2018-10-30 17:03:42 104

原创 重写equals

    public boolean equals(Object o) {        if(this == o) {            return true;        }        Person123 p = (Person123)o;                if(o !=null && o.getClass() ==Person123.cl...

2018-10-30 16:56:00 100

转载 打印圆

public class printCircle {    // r圆的半径    public static void prinf(int r) {        // i代表每一行        for (int i = 0; i <= 2 * r; i += 2) {            // 圆上点到竖着半径的距离            long y = Math.ro...

2018-10-28 18:49:21 283

原创 打印九九乘法表

public class MultiplicationTable {    public static void print() {        for (int i = 1; i <= 9; i++) {            for (int j = 1; j <= i; j++) {                System.out.print(i + "x" + j...

2018-10-28 17:33:15 85

原创 打印菱形

public class IsoscelesTriangle {    public static void print(int n) {        for (int j = 1; j <= n; j++) {            for (int i = j; i < n; i++) {//控制空格的个数                System.out.print(...

2018-10-28 17:32:58 87

原创 复制文件应用FileIO流

import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;public class CopyFile {    public static void main(String[] args) {        long s = System.currentTimeMi...

2018-10-28 15:52:16 207

原创 处理FileOutputStream异常

public class IOException {    public static void main(String[] args) {        // 1.建立输出流对象        // 2.处理异常        FileOutputStream fos = null;        try {            File file = new File("e:d....

2018-10-28 14:19:45 2029

原创 参数交换输出结果的不同好好思考

public class ParameterTransfer {    //定义一个两个参数交换的方法    public static void swap(int a,int b) {        int temp = a;//用一个临时变量保存a的值        a = b;        b = temp;    }    //实现调用    public static ...

2018-10-28 11:18:06 136

原创 了解一下

Java语言有哪些优点?1.Java为纯面向对象的语言。万物皆对象;2、平台无关性。“一次编译,到处运行”;JVM是关键的转换器,向上为字节码文件提供同一个接口,向下为各平台提供不同的接口,做到了先编译,后解释;3、Java提供了很多内置的类库,简化了程序设计,缩短了项目开发周期,最重要的是提供了垃圾回收器;4、提供了Web应用开发的支持;如Applet、Servlet、JSP可以...

2018-10-28 10:42:19 81

原创 关于static的一些理解

分两种情况来了解;static修饰成员变量时,该变量属于类变量;什么时候适合用它来修饰成员变量呢?当一个数据具有共享性质的时候就应该考虑使用;也可以理解数据具有聚合性,例如公司的部门名称,它是相对于部门成员共享的,部门成员聚合在一起形成了这个部门; static修饰成员方法时,该方法属于类方法;要注意该方法只能调用静态成员变量,非静态成员变量是无法调用的;为什么呢?因为static...

2018-10-27 21:01:15 118

原创 阳阳买苹果

    public static double getAvg() {        int day = 0;        int apple = 2;        double money = 0;        while(apple<100) {            money += 0.8*apple;            day++;            a...

2018-10-27 20:08:23 224

原创 递归的一些用法

    public static void main(String[] args) {        getExeFile(new File("e:\\BaiduNetdiskDownload"));    }        public static void getExeFile(File file) {        File[] files = file.listFiles(n...

2018-10-27 18:14:47 84

原创 金融数

    private static String jin(double num) {        DecimalFormat f = new DecimalFormat("#,###.00");        return f.format(num);    }                public static void main(String[] args) {   ...

2018-10-26 07:53:29 97

原创 求一个数组中的元素的最大值

public class array1 {    public static void main(String[] args) {        int[] arr = {1,3,4,5,6,7};        int max = arr[0];        for (int i = 1; i < arr.length; i++) {            if(max<...

2018-10-25 20:29:20 2914

原创 随机字符串

public class RandomStr {    public static void main(String[] args) {        //定义一个空字符串        String str = "";        //进行6次循环        for (int i = 0; i < 6; i++) {            int val = (int)(...

2018-10-24 16:11:29 97

原创 静态代码块

    static {        /**         * 静态代码块:在JVM加载类的时候开始执行         *          */        System.out.println("静态代码块");            }...

2018-10-23 10:55:18 69

原创 对象作为参数

public class Stu {    private String name;    private int age;        public Stu(String name,int age) {        this.name = name;                this.age = age;    }    public void setName(Str...

2018-10-22 11:27:56 1209

原创 数组传参简化代码

    public static void showMainMenu(String [] menus) {//数组menus作为形参        for (int i = 0; i < menus.length; i++) {            System.out.print(i+1+"."+menus[i]);        }    }            pu...

2018-10-22 11:03:30 134

原创 学习Java 二十天

第一阶段学完异常,对java基础有了比较深刻的了解,之前学习C的时候越到后面越感觉没啥意思,这次学习java,勾起了我的极大的兴趣,它的面向对象思想十分有趣,很多问题解决起来感觉会简单许多。但离真正理解其继承、多态的特性及灵活运用还需一段时间的积累。下周将java基础阶段全部完成后,决定在自己做个小项目将所学知识都用上。 我坚信,自己将成为java最疯狂的粉丝了。...

2018-10-21 15:18:02 79

原创 冒泡排序

public class BubbleSort {    public static void main(String[] args) {        int [] array = new int [] {2,4,6,7,3,5};//冒泡排序进行升序排列        for (int i = 0; i < array.length; i++) {//遍历数组          ...

2018-10-18 15:00:22 88

原创 去除数组中重复数据

public class DeleteDuplicate {    public static void main(String[] args) {        int[] array = new int[] { 1, 3, 4, 5, 6, 4, 3, 2, 3, 4, 5 };// 要求将重复的数字去掉        for (int i = 0; i < array.lengt...

2018-10-18 14:39:09 447

原创 关于进制的转换

    public static void main(String[] args) {        int i =10;        System.out.println(Integer.toBinaryString(i));//转二进制        System.out.println(Integer.toOctalString(i));//转八进制        System....

2018-10-17 16:45:40 83

原创 关于存取钱余额的计算

public class Account {    private int money;    //存款业务     public void saveMoney(int money) {        this.money += money;    }    //取款业务    public void takeMoney(int money) {        this.money...

2018-10-16 18:15:28 237

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除