![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JavaSE
Java基础
毕竟尹稳健
凸头小白
展开
-
Java中JavaBean对象和Map的互相转换
这篇博客是通过反射进行实现转换的在学习redis中,发现了一个知识点,就是Java对象转map,视频中的内容是通过hutool工具转换的,但是我们学习者肯定不能只通过工具来进行转换,更多的是通过这个知识点学习到他的底层是如何进行转换的。就是通过自定义注解来判断是否需要递归转换嵌套的话,应该还有其他方法可以研究一下在实际项目中相信大多数人都使用过工具类,比如说commons下的和hutool工具类,但是我们只是知道如何调用这个API,而不知道他方法的底层是通过什么样的思路进行实现的。原创 2022-11-09 20:02:04 · 2329 阅读 · 0 评论 -
JDBCUtils和druidJdbcutils
public class JDBCUtilsByDruid { private static DataSource dataSource; static { Properties properties = new Properties(); try { properties.load(new FileInputStream("src\\druid.properties")); dataSource = Dru原创 2022-01-21 14:08:33 · 185 阅读 · 0 评论 -
Druid连接MySQL
@Test public void testDruid() throws Exception { Properties properties = new Properties(); properties.load(new FileInputStream("src\\druid.properties")); DataSource dataSource = DruidDataSourceFactory.createDataSource(properties原创 2022-01-21 14:00:01 · 1252 阅读 · 0 评论 -
C3P0连接MySQL
@Test public void testC3P0() throws IOException, PropertyVetoException, SQLException { // 设置c3p0连接数据源 ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource(); // 读取配置文件 Properties properties = new Prope原创 2022-01-21 13:43:28 · 1151 阅读 · 0 评论 -
ArrayList扩容源码
进行debug调试 ArrayList list = new ArrayList(8); // 断点 for (int i = 0; i <= 10; i++) { list.add(i); } for (int i = 11; i <= 15; i++) { list.add(i); } list.add(100); list.add原创 2021-10-04 15:01:25 · 65 阅读 · 0 评论 -
Integer的创建机制
> 原因:在创建Integer对象时会调用valueOf 方法.// static final int low = -128;// static final int high = 127;// public static Integer valueOf ( int i){// if (i >= IntegerCache.low && i <= IntegerCache.high)// .原创 2021-09-15 19:30:13 · 145 阅读 · 0 评论 -
Java中equals和==的区别
equals:是Object类中的方法,只能判断引用类型默认判断的是地址是否相等,子类中往往重写该方法,用于判断内容是否相等。比如 Integer,String【看看String 和 Integer的equals 源代码】Object中equals源码:public boolean equals(Object obj) { return (this == obj); }Integer中equals源码:public boolean equals(Object ob..原创 2021-08-24 17:16:23 · 68 阅读 · 0 评论 -
Java的动态绑定机制
java的动态绑定机制 1.当调用对象方法的时候,该方法会和该对象的内存地址/运行类型绑定 2.当调用对象属性时,没有动态绑定机制,哪里声明,那里使用public class Dynamic_ { public static void main(String[] args) {// a为编译类型,B为运行类型 A a = new B(); System.out.println(a.sum());//30 Sys...原创 2021-08-23 15:55:17 · 79 阅读 · 0 评论 -
汉罗塔java
public class HanLuoTower { public static void main(String[] args) { Tower tower = new Tower(); tower.move(2,'A','B','C'); }}class Tower{ public void move(int num,char a,char b,char c){ if (num == 1){ System原创 2021-08-11 10:23:46 · 86 阅读 · 0 评论 -
小老鼠找家家
public class MiGong { public static void main(String[] args) { int[][] map = new int[8][7]; map[3][1] = 1; map[3][2] = 1; for (int i = 0; i < map.length; i++) { for (int j = 0;j<map[i].length;j++){原创 2021-08-11 10:10:50 · 70 阅读 · 0 评论 -
数组插入数据(定位+扩容)
int[] arr = {10,12,45,90};// **定位器**int index = 0;Scanner sc = new Scanner(System.in);System.out.println("请输入一个数字:");int num = sc.nextInt();int[] new_arr = new int[arr.length + 1];// 找到插入数据的位置for (int i = 0; i < arr.length; i++) { if (num>原创 2021-07-14 10:24:49 · 146 阅读 · 0 评论