1 Star 0 Fork 0

yobing / yobing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.xml 14.22 KB
一键复制 编辑 原始数据 按行查看 历史
yobing 提交于 2020-11-14 17:24 . fuxi
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>油饼同学的博客</title>
<link>https://yobing.gitee.io/</link>
<description>Recent content on 油饼同学的博客</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh-cn</language>
<copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright>
<lastBuildDate>Fri, 28 Aug 2020 00:00:00 +0000</lastBuildDate>
<atom:link href="https://yobing.gitee.io/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>20201111 反射</title>
<link>https://yobing.gitee.io/posts/20201111-%E5%8F%8D%E5%B0%84/</link>
<pubDate>Wed, 11 Nov 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201111-%E5%8F%8D%E5%B0%84/</guid>
<description>反射 (Reflection) 反射是Java被视为动态语言的关键,反射机制允许程序在执行期间借助于Reflection API取得任何类的内部信息,并能直接操作任意对象的内部属性及方法。Class c = Class.forName(&amp;quot;java.lang.String&amp;quot;)
加载完类之后,在堆内存的方法中就产生了一个Class类型的对象(一个类只有一个Class对象),这个对象就包含了完整的结构信息。 我们可以通过这个对象看到类的结构。
反射机制提供的功能:
判断对象所属的类 构造任意一个类的对象 判断任意一个类所具有的成员变量和方法 获取泛型信息 调用任意一个对象的成员变量和方法 处理注解 生成动态代理 优点 :可以实现动态创建对象和编译,体现出很大的灵活性
缺点:对性能有影响。使用反射基本上是一种解释操作,我们可以告诉JVM,我们希望做什么并且它满足我们的要求。这类操作总是慢于直接执行相同的操作。
反射相关的主要API:
java.lang.Class : 代表一个类 java.lang.reflect.Method : 代表类的方法 java.lang.reflect.Field : 代表类的成员变量 java.lang.reflect.Constructor : 代表类的构造器 package io.gitee.注解和反射; //什么叫反射 public class Test01 extends Object { public static void main(String[] args) throws ClassNotFoundException { //通过反射获取类的Class对象 Class c1 = Class.</description>
</item>
<item>
<title>20201104 注解</title>
<link>https://yobing.gitee.io/posts/20201104-%E6%B3%A8%E8%A7%A3/</link>
<pubDate>Wed, 04 Nov 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201104-%E6%B3%A8%E8%A7%A3/</guid>
<description>注解 (Annotation) Annotation 是jdk5.0开始引入的新技术
作用:
不是程序本身,可以对程序作出解释(这点和注释[comment]没有区别) 可以被其他程序(比如:编译器)读取 Annotation的格式
注解是以“@注解名”在代码中存在的,还可以添加一些参数值。例:@SuppressWarmngs(value=&amp;quot;unchecked&amp;quot;) 用处:可以附加在package、class、method、field等上面,相当于给他们添加了格外的辅助信息,可以通过反射机制编程实现对这些数据的访问。
内置注解 内置注解 解释 @Override 此注释只适用于修饰方法,表示一个方法声明打算重写超类中的另一个方法声明 @Deprecated 此注释可以用于修饰方法、属性、类,表示不鼓励使用,通常是因为很危险或者有更好的选择 @SuppressWarnings 用来一致编译时的警告信息,需要添加参数才能使用 [&#39;all&#39;,&#39;unchecked&#39;,&#39;value={&amp;ldquo;unchecked&amp;rdquo;,&amp;ldquo;deprecation&amp;rdquo;}&#39;] 元注解 元注解的作用就是负责注解其他注解,Java定义了4个便准的meta-annotation类型,他们被用来提供对其他annotation类型作说明。
元注解 解释 @Target 用于描述注解的使用范围 @Retention 表示需要在什么级别保存该注释纤细,用于描述注解的生命周期 (SOURCE &amp;lt; CLASS &amp;lt; RUNTIME) @Document 说明该注解将被包含在javadoc中 @Inherited 说明子类可以继承父类中的注解 package io.</description>
</item>
<item>
<title>20201023 反射</title>
<link>https://yobing.gitee.io/posts/20201023-%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/</link>
<pubDate>Fri, 23 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201023-%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/</guid>
<description>设计模式 简介: 设计模式就是可以重复利用的解决方案。可以减少代码之间的耦合。 在不修改基本类的条件下,对功能进行添加和升级。 装饰者设计模式 使用场景:给某个对象的功能进行扩展时,可以考虑使用。
比如:BufferedReader可以对FileReader进行装饰。
拉面加料接口 package io.gitee.Decorate; public interface NoodleDecorate { //向拉面中加料 void addThings(); } 拉面:继承加料接口,重写addThings方法 package io.gitee.Decorate; public class Noodle implements NoodleDecorate{ @Override public void addThings() { System.out.println(&amp;#34;加肉&amp;#34;); System.out.println(&amp;#34;加香菜&amp;#34;); System.out.println(&amp;#34;加萝卜&amp;#34;); System.out.println(&amp;#34;加白菜&amp;#34;); } } 加料的装饰类,继承拉面类 package io.gitee.Decorate; public class ChiliNoodle implements NoodleDecorate{ private Noodle noodle; //传入要加辣椒的拉面 public ChiliNoodle(Noodle noodle) { this.noodle = noodle; } @Override public void addThings() { noodle.</description>
</item>
<item>
<title>20201022 IO流</title>
<link>https://yobing.gitee.io/posts/20201022-io%E6%B5%81/</link>
<pubDate>Thu, 22 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201022-io%E6%B5%81/</guid>
<description>IO流 概述 主要的作用是用来处理设备之间的数据传输。(转换为字节,传到另外的地方,再转换回来)。
常用的IO流的类
分类 按照流向分类: 输入流 (InputStream 、Reader):从硬盘或者其他地方读到内存中 输出流 (OutputStream、Writer):从内存读到硬盘或者其他地方 按照操作类型分类: 字节流 (InputStream 、OutputStream) :字节流可以操作任何数据,因为计算机中的数据都是以字节形式存储的 字符流 (Reader、Writer):字符流只能操作纯字符数据,防止乱码。 绝对路径和相对路径 绝对路径 值文件在硬盘上真正存在的路径。 D:\Java\HelloWorld.java 相对路径 指某个文件的路径和别的文件的路径关系。 \images\monkey.png jdk7中的新写法 package io.gitee.stream; import java.io.*; /** * 需求:将Java.txt文件复制到file文件夹中,并重命名good.txt */ public class FileCopy { public static void main(String[] args) { try ( FileInputStream fis = new FileInputStream(&amp;#34;src&amp;#34; + File.separator + &amp;#34;io&amp;#34; + File.</description>
</item>
<item>
<title>20201015 集合</title>
<link>https://yobing.gitee.io/posts/20201015-%E9%9B%86%E5%90%88/</link>
<pubDate>Thu, 15 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201015-%E9%9B%86%E5%90%88/</guid>
<description>集合类 数组长度固定,如果要改变数组的长度需要创建新的数组将旧的数组里面的元素拷贝过去,使用不方便。
Java提供了一些集合类,能够存储任意长度的对象,长度可以随着元素的增加而增加。随着元素的减少而减少,使用方便。
可以简单理解为自动扩容的数组
集合继承体系图
[interface] Collection
[interface] List: 有序,存取顺序一致
[class] ArrayList [class] LinkedList [class] Vector [interface] Set: 无序,存取顺序不一致,不能存储重复数据
[class] HashSet [class] TreeSet [interface] Queue: 先进先出
[class] PriorityQueue 数组和集合的区别 区别1: 数组既可以存储基本数据类型(存储的数值),又可以存储引用数据类型(地址值) 集合只能存储引用数据类型(对象),如果存储基本数据类型是,会自动装箱变成对应的包装类 区别2: 数组长度固定 集合的长度是可变的 数组和集合的相互转化 package io.gitee.集合; import java.util.ArrayList; import java.util.Arrays; import java.</description>
</item>
<item>
<title>20201014 静态代理模式</title>
<link>https://yobing.gitee.io/posts/20201014-%E9%9D%99%E6%80%81%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8F/</link>
<pubDate>Wed, 14 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201014-%E9%9D%99%E6%80%81%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8F/</guid>
<description>静态代理模式 静态代理模式总结
真实对象和代理对象都要实现同一个接口
代理对象要代理真实角色
好处:
代理对象可以做真实对象做不了的事情
真实对象专注做自己的事情
package io.gitee.线程; /** * 静态代理模式总结 * 真实对象和代理对象都要实现同一个接口 * 代理对象要代理真实角色 * * 好处: * 代理对象可以做真实对象做不了的事情 * 真实对象专注做自己的事情 */ public class StaticProxy { public static void main(String[] args) { // new Thread(()-&amp;gt;{ // System.out.println(&amp;#34;i love u&amp;#34;); // }).start(); //创建对象时,对象的参数也是对象(You是真实结婚对象) // WeddingCompany weddingCompany = new WeddingCompany(new You()); // weddingCompany.HappyMarry(); //Lambda表达式简写上面的两句代码 new WeddingCompany(new You()).</description>
</item>
<item>
<title>20201013 Lambda表达式</title>
<link>https://yobing.gitee.io/posts/20201013-lambda%E8%A1%A8%E8%BE%BE%E5%BC%8F/</link>
<pubDate>Tue, 13 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201013-lambda%E8%A1%A8%E8%BE%BE%E5%BC%8F/</guid>
<description>Lambda表达式 函数式接口 Functional Interface 是学习Java8 Lambda表达式的关键所在
任何接口,如果只包含唯一一个抽象方法,那么他就是一个函数式接口 对于函数式接口,可以通过Lambda表达式来创建该接口的对象 Lambda表达式推导过程:
package io.gitee.线程; /** * 推到Lambda表达式 */ public class LambdaTest&amp;lt;like&amp;gt; { //3.静态内部类 static class Like2 implements ILike{ @Override public void lambda() { System.out.println(&amp;#34;静态内部类实现:i like u2&amp;#34;); } } public static void main(String[] args) { ILike like = new Like(); like.lambda(); like = new Like2(); like.lambda(); // 4.局部内部类 class Like3 implements ILike{ @Override public void lambda() { System.out.println(&amp;#34;局部内部类:i like u3&amp;#34;); } } like = new Like3(); like.</description>
</item>
<item>
<title>20201010 1 BigDecima(高精度浮点)</title>
<link>https://yobing.gitee.io/posts/20201010-1-bigdecimal%E9%AB%98%E7%B2%BE%E5%BA%A6%E6%B5%AE%E7%82%B9/</link>
<pubDate>Sat, 10 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201010-1-bigdecimal%E9%AB%98%E7%B2%BE%E5%BA%A6%E6%B5%AE%E7%82%B9/</guid>
<description>BigDecimal类 对数字精度特别敏感,不容有误差
相比float,double,精度高,但是牺牲了速度
package io.gitee.yobing; import java.math.BigDecimal; public class BigDecimalClass { public static void main(String[] args) { System.out.println(2.0-1.1); //开发中也不要这样写,精度还是不够 BigDecimal b1 = new BigDecimal(2.0); BigDecimal b2 = new BigDecimal(1.1); System.out.println(b1.subtract(b2)); //开发中建议这样使用 BigDecimal b3 = new BigDecimal(&amp;#34;2.0&amp;#34;); BigDecimal b4 = new BigDecimal(&amp;#34;1.1&amp;#34;); System.out.println(b3.subtract(b4)); //也可这样用 BigDecimal b5 = BigDecimal.valueOf(2.0); BigDecimal b6 = BigDecimal.valueOf(1.1); System.out.println(b5.subtract(b6)); } } </description>
</item>
<item>
<title>20201010 2 BigInteget(超大数)</title>
<link>https://yobing.gitee.io/posts/20201010-2-biginteger%E8%B6%85%E5%A4%A7%E6%95%B0/</link>
<pubDate>Sat, 10 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201010-2-biginteger%E8%B6%85%E5%A4%A7%E6%95%B0/</guid>
<description>BigInteger类 数字太大,long类型也放不下,可以用BigInteger
package io.gitee.yobing; import java.math.BigInteger; public class BigIntegerClass { public static void main(String[] args) { BigInteger b1 = new BigInteger(&amp;#34;100&amp;#34;); BigInteger b2 = new BigInteger(&amp;#34;2&amp;#34;); System.out.println(b1.add(b2));//b1+b2 System.out.println(b1.subtract(b2)); System.out.println(b1.multiply(b2)); System.out.println(b1.divide(b2)); BigInteger[] arr = b1.divideAndRemainder(b2); for (BigInteger i:arr ) { System.out.print(i+&amp;#34; &amp;#34;); } } } </description>
</item>
<item>
<title>20201010 3 DecimalFormat(数字格式化)</title>
<link>https://yobing.gitee.io/posts/20201010-3-decimalformat%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F%E5%8C%96/</link>
<pubDate>Sat, 10 Oct 2020 23:17:45 +0800</pubDate>
<guid>https://yobing.gitee.io/posts/20201010-3-decimalformat%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F%E5%8C%96/</guid>
<description>DecimalFormat类 对格式要求
package io.gitee.yobing; import java.text.DecimalFormat; public class DecimalFormatClass { public static void main(String[] args) { //人民币 String RMB = DecimalFormat.getCurrencyInstance().format(1234567); System.out.println(RMB); DecimalFormat df = new DecimalFormat(&amp;#34;###,###&amp;#34;); System.out.println(df.format(123456)); //加千分位,保留2位小数 DecimalFormat df1 = new DecimalFormat(&amp;#34;###,###.##&amp;#34;); System.out.println(df1.format(123456.222)); //加千分位,保留4位小数,不够补0 DecimalFormat df2 = new DecimalFormat(&amp;#34;###,###.0000&amp;#34;); System.out.println(df2.format(123456.222)); } } </description>
</item>
</channel>
</rss>
1
https://gitee.com/yobing/yobing.git
git@gitee.com:yobing/yobing.git
yobing
yobing
yobing
master

搜索帮助