
java基础
天-方-夜-谭
Hello World
展开
-
【无标题】
JDBC工具类出现错误:Could not initialize class util.JDBCUtils解决办法。原创 2022-09-24 21:42:36 · 434 阅读 · 1 评论 -
Arrays类操作数组常用方法
Arrays类操作数组常用方法介绍import java.util.Arrays;//Arrays类操作数组常用方法举例public class AraysTest { public static void main(String[] args) { /* binarySearch(type[] a,type key) 使用二分法查询key元素在数组中的索引 如不包含key就返回负数。使用时数组元素必须有序。原创 2022-05-11 16:14:43 · 258 阅读 · 0 评论 -
JAVA二维数组两种初始化方法以及四种遍历方法
JAVA二维数组两种初始化方法以及四种遍历方法public class Arrays { public static void main(String[] args) { //动态初始化 int[][] arr = new int[5][]; System.out.println("==========================================="); /* for循环遍历 此时原创 2022-05-01 21:21:14 · 4403 阅读 · 0 评论 -
Druid连接池技术
所需jar包地址:https://download.youkuaiyun.com/download/jb18602754485/15565930druid工具类:import com.alibaba.druid.pool.DruidDataSourceFactory;import javax.sql.DataSource;import java.io.IOException;import java.io.InputStream;import java.sql.Connection;import java原创 2021-03-04 19:15:22 · 115 阅读 · 1 评论 -
c3p0连接池
java代码import com.mchange.v2.c3p0.ComboPooledDataSource;import javax.sql.DataSource;import java.sql.Connection;import java.sql.SQLException;public class Jdbc_4 { public static void main(String[] args) throws SQLException { DataSource ds =原创 2021-03-04 19:09:07 · 96 阅读 · 1 评论 -
JDBC连接MySQL数据库
import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Statement;public class Jdbc { public static void main(String[] args) throws ClassNotFoundException, SQLException { //zhucequdong原创 2021-03-04 17:20:55 · 87 阅读 · 1 评论 -
JDBC连接MySQL数据库(使用配置文件)
JDBC连接数据库工具类:package it.cast;import java.io.FileReader;import java.io.IOException;import java.net.URL;import java.sql.*;import java.util.Properties;public class JDBCUTILS { private static String url; private static String user; private原创 2021-03-04 17:07:14 · 1704 阅读 · 2 评论 -
JAVA通过反射运行配置文件指定内容
JAVA通过反射运行配置文件指定内容public class test { public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Properties p = new Prop原创 2021-02-06 22:15:59 · 187 阅读 · 0 评论 -
JAVA通过反射实现向ArrayList<Integer>集合中添加字符串数据
反射实现向ArrayList集合中添加字符串数据public class test { public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { ArrayList<Integer> array=new ArrayList<Integer>(); array.a原创 2021-02-06 21:49:22 · 1171 阅读 · 2 评论 -
JAVA模拟实现生产者消费者同步问题
JAVA模拟实现生产者消费者同步问题模拟缓存区public class Box { private int milk; private Boolean state = false; public synchronized void putMilk(int milk) { if (state) { try { wait(); } catch (InterruptedException原创 2021-02-04 16:19:50 · 171 阅读 · 0 评论 -
JAVA多线程模拟卖票
JAVA多线程模拟卖票public class SellTicket implements Runnable { private int tickets = 100; private Object object = new Object(); @Override public void run() { while (true) { synchronized (object) { if (tickets原创 2021-02-04 14:56:28 · 129 阅读 · 0 评论 -
java实现单级文件夹和多级文件夹的复制
单级文件夹的复制public class file9 { public static void main(String[] args) throws IOException { File src = new File("C:\\case");//源 String name = src.getName(); //System.out.println(name); File destfolder = new File("C:\\itcas原创 2021-02-03 20:52:34 · 173 阅读 · 0 评论 -
java实现视频文件的复制(四种方法)
java实现视频文件的复制(四种方法)public class file_01 { public static void main(String[] args) throws IOException { long start = System.currentTimeMillis(); System.out.println(start); way1(); /* way2(); way3();原创 2021-02-02 17:34:30 · 1585 阅读 · 1 评论