java笔记
是吃货不是贝爷
加油吧~
展开
-
2021.8.18笔记 数据库连接池
概述实现介绍原创 2021-08-18 17:39:37 · 94 阅读 · 0 评论 -
2021.8.9笔记 request
request原理继承体系获取请求行数据_方法获取请求头数据获取请求体数据获取请求参数通用方式原理继承体系获取请求行数据_方法其中比较重要的为2.获取虚拟目录和5.获取请求URI@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = req原创 2021-08-09 17:10:35 · 72 阅读 · 0 评论 -
2021.8.7笔记 servlet
概述弄了好久一直404。。。解决方法就是deployment里的application context改成/servlet执行原理生命周期方法import javax.servlet.*;import java.io.IOException;public class ServletDemo2 implements Servlet { /** * 在servlet被创建时执行,只会执行一次 * @param servletConfig * @thr原创 2021-08-07 20:56:42 · 58 阅读 · 0 评论 -
2021.8.7笔记 Tomcat
安装1.安装网址:https://tomcat.apache.org/2.下载相应版本:因为教程用的8,所以下载8了(左边的菜单栏)3.解压压缩包(安装目录不要有中文和空格)启动bin目录下的startup双击,弹出cmd,加载完别关掉输入网址http://xxx.xxx.xxx.xxx:8080/(ip地址)或者http://localhost:8080/会弹出一个tomcat自带的页面如果是访问别人的,用ip地址,访问自己的,可以用localhost关闭配置第三种的好处就原创 2021-08-07 16:06:52 · 124 阅读 · 1 评论 -
2021.8.6笔记 jsoup
jsoup对象import org.jsoup.Jsoup;import org.jsoup.nodes.Document;import org.jsoup.nodes.Element;import org.jsoup.select.Elements;import java.io.File;import java.io.IOException;import java.net.URL;public class xmlJsoupPra { public static void m原创 2021-08-06 17:06:54 · 83 阅读 · 0 评论 -
2021.7.1笔记 注解
概念原创 2021-07-01 13:00:29 · 68 阅读 · 0 评论 -
2021.6.30笔记 反射
概述获取字节码Class对象的三种方式Fieldspublic class Person { public String name; public int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; }原创 2021-06-30 19:17:02 · 84 阅读 · 0 评论 -
2021.6.30笔记 Junit
Junit测试概述Junit使用步骤@Before&@After测试概述Junit使用步骤public class Calculator { public static int method(int a, int b) { return a + b; }}import com.learning.demo03.Calculator;import org.junit.Assert;import org.junit.Test;public cl原创 2021-06-30 14:30:26 · 99 阅读 · 1 评论 -
2021.6.28笔记 方法引用
基本介绍public class NewDemo { public static void printData(NewInterface inter) { inter.print("HelloWorld"); } public static void main(String[] args) { printData(/*s->{ System.out.println(s); }*/System.out:原创 2021-06-28 17:41:13 · 49 阅读 · 0 评论 -
2021.6.10笔记 递归
递归递归概念&分类&注意事项练习:用递归计算1-n之间数的和练习:用递归计算1乘到i的值练习:递归打印多级目录递归概念&分类&注意事项ps:public FileList() { FileList(); //报错}练习:用递归计算1-n之间数的和public class RecurrenceClass { public static void main(String[] args) { int sumAll =原创 2021-06-10 21:15:44 · 55 阅读 · 0 评论 -
2021.6.26笔记 Stream流
过滤数据,遍历集合import java.util.ArrayList;public class StreamClass { public static void main(String[] args) { ArrayList<String> arr = new ArrayList<>(); arr.add("晁武德"); arr.add("新德里"); arr.add("张无忌"); a原创 2021-06-26 11:28:26 · 1386 阅读 · 0 评论 -
2021.6.25笔记 Function
applypublic class FunctionInter { public static void method(String s, Function<String,Integer> fun) { int apply = fun.apply(s); System.out.println(apply); } public static void main(String[] args) { String s =原创 2021-06-25 20:01:58 · 56 阅读 · 0 评论 -
2021.6.25笔记 Predicate练习
要求:筛选出名字小于5以及性别为女的字符串(之前的代码一直没截取import,到用时候发现还需要一个一个补上,血的教训。。)import java.util.ArrayList;import java.util.function.Predicate;public class PredicatePra { public static ArrayList<String> departEle(String[] arr, Predicate<String> pre1, Pr原创 2021-06-25 11:54:35 · 51 阅读 · 0 评论 -
2021.6.22笔记 函数式接口
概念与定义@FunctionalInterfacepublic interface Functional { public abstract void method();}原创 2021-06-22 23:26:43 · 48 阅读 · 0 评论 -
2021.6.19笔记 综合案例:文件上传
原理客户端代码public class PracticeClient { public static void main(String[] args) throws IOException { FileInputStream fips = new FileInputStream("H:\\test\\aa.txt"); Socket so = new Socket("175.0.0.1",8888); OutputStream ops = so原创 2021-06-19 13:52:38 · 79 阅读 · 0 评论 -
2021.6.18笔记 TCP通信
客户端代码实现public class NewClass { public static void main(String[] args) throws IOException { Socket so = new Socket("172.1.2.50",8000); OutputStream ops = so.getOutputStream(); ops.write("你好呀".getBytes()); so.close();原创 2021-06-18 19:13:33 · 94 阅读 · 1 评论 -
2021.6.18笔记 打印流
public class PrintClass { public static void main(String[] args) throws FileNotFoundException { PrintStream ps = new PrintStream("H:\\test\\mm.txt"); ps.write(97); ps.println(97); ps.close(); }}public class Pri..原创 2021-06-18 12:45:42 · 89 阅读 · 0 评论 -
2021.6.17笔记 序列化和反序列化
序列化和反序列化概述对象的序列化流——ObjectOutputStream对象的反序列化流——ObjectInputStream概述对象的序列化流——ObjectOutputStreampublic class Person implements Serializable { //不implements的话会异常 private String name; private int age; public Person() { } public Per原创 2021-06-17 18:18:51 · 64 阅读 · 1 评论 -
2021.6.17笔记 转换流
转换流的原理OutputStreamWriter介绍&代码实现public class OutputStrW { public static void main(String[] args) throws IOException { OutputStreamWriter opsw = new OutputStreamWriter(new FileOutputStream("H:\\test\\aa.txt"),"GBK"); opsw.write(原创 2021-06-17 15:22:41 · 52 阅读 · 1 评论 -
2021.6.14笔记 缓冲流
缓冲流的原理public class Buffer { public static void main(String[] args) throws IOException { FileOutputStream fops = new FileOutputStream("F:\\test\\aa.txt"); BufferedOutputStream bops = new BufferedOutputStream(fops); bops.write(原创 2021-06-14 16:41:57 · 58 阅读 · 0 评论 -
2021.6.13笔记 Properties集合
Properties集合存储数据,遍历数据原创 2021-06-13 22:08:59 · 77 阅读 · 0 评论 -
2021.6.11笔记 IO
IOIO概述(概念&分类)字节输出流OutputStream&FileOutputStreamIO概述(概念&分类)字节输出流OutputStream&FileOutputStream 1.写入数据到文件(FileOutputStream)public class OutputStreamC { public static void main(String[] args) throws IOException { FileOutput原创 2021-06-11 17:14:18 · 81 阅读 · 0 评论 -
2021.6.11笔记 FileFilter和FilenameFilter
FileFilter和FileNameFilter概述public class FileFilterImpl implements FileFilter { @Override public boolean accept(File pathname) { if(pathname.isDirectory()) { return true; } return pathname.getName().toLowerCase原创 2021-06-11 13:00:41 · 142 阅读 · 1 评论 -
2021.6.9笔记 File类
File类File类概述File类的静态成员变量绝对路径和相对路径File类的构造方法File类概述File类的静态成员变量public class FileStaticMethod { public static void main(String[] args) { String pathSeparator = File.pathSeparator; System.out.println(pathSeparator); //结果为;(windo原创 2021-06-09 19:41:43 · 104 阅读 · 0 评论 -
2021.6.8笔记 线程池 Lambda
线程池的概念和原理public class RunImpl implements Runnable{ @Override public void run() { System.out.println(Thread.currentThread().getName() + "哈哈"); }}public class ThreadPool { public static void main(String[] args) { Executor原创 2021-06-08 19:59:45 · 149 阅读 · 0 评论 -
2021.6.3笔记 多线程
并发与并行进程概念线程概念线程调度原创 2021-06-03 12:24:49 · 163 阅读 · 0 评论 -
2021.5.31笔记 异常
throw关键字public class ExceptionClass { public static void main(String[] args) { int[] arr = null; int element = getElement(arr, 4); System.out.println(element); } public static int getElement(int[] arr, int index) {原创 2021-05-31 20:40:51 · 64 阅读 · 0 评论 -
2021.5.30笔记 可以按顺序的斗地主牌
基本图解原创 2021-05-30 19:29:56 · 103 阅读 · 0 评论 -
2021.5.30笔记 Debug追踪
具体,由于是操作题,可参考置顶java笔记相关网站视频的P285原创 2021-05-30 19:05:39 · 52 阅读 · 0 评论 -
2021.5.27笔记 Map集合
Map概述原创 2021-05-27 13:31:19 · 68 阅读 · 0 评论 -
2021.5.26笔记 Collections集合
addAll&shufflepublic class AddAll { public static void main(String[] args) { ArrayList<String> str = new ArrayList<>(); Collections.addAll(str,"a","b","c"); //第一个参数为涉及到的集合,后面为添加的数据,可一次性添加多个元素 System.out.println(原创 2021-05-26 15:06:36 · 85 阅读 · 0 评论 -
2021-05-26笔记 可变参数
可变参数一般涉及到的是已知参数类型,不知道参数数量的情况格式为参数括号中(参数类型…参数名称)那么当类型为Object的时候,可以接受任意数据类型public class Changeable { public static void main(String[] args) { method(1,2); method(1,2,5); } public static int method(int...arr) { //底层创建的为数组,并将传入的参原创 2021-05-26 12:10:27 · 34 阅读 · 0 评论 -
2021.5.24笔记 Set集合
HashSet集合public class HashSetPractice { public static void main(String[] args) { Set<Integer> str1 = new HashSet<>(); str1.add(1); str1.add(2); str1.add(3); str1.add(1); //不允许添加重复元素,添加失败原创 2021-05-24 17:36:05 · 64 阅读 · 0 评论 -
2021.5.24笔记 List集合
List接口中带索引的方法1.add:增加2.get:获取3.remove:移除并返回4.set:设置public class ListPractice { public static void main(String[] args) { List<String> list = new ArrayList<>(); //多态 list.add("a"); list.add("b"); list.add原创 2021-05-24 17:15:03 · 57 阅读 · 0 评论 -
2021.5.24笔记 斗地主
public class PokerGame { //准备牌 //洗牌 //发牌 //看牌 public static void main(String[] args) { ArrayList<String> pokersAll = new ArrayList<>(); pokersAll.add("小王"); //先往牌中加入大王小王 pokersAll.add("大王");原创 2021-05-24 12:31:24 · 66 阅读 · 0 评论 -
2021.5.20笔记 泛型
泛型图解原创 2021-05-20 14:58:13 · 63 阅读 · 1 评论 -
2021.5.19笔记 Collection集合
概述数组中存储的是同一类型的元素,可以存储基本数据类型值和对象;集合存储的都是对象,而且对象的类型可以不一致。集合的框架:Collection的一些方法public class CollectionClass { public static void main(String[] args) { Collection<String> coll = new ArrayList<>(); coll.add("野原新之助");原创 2021-05-19 14:42:48 · 71 阅读 · 1 评论 -
2021.5.18笔记 包装类
包装类图解装箱与拆箱装箱:把基本类型的数据,包装到包装类中(基本数据类型=>包装类)构造方法(已过时):Integer(int value)构造一个新分配的Integer对象,它表示指定的int值Integer(String s)构造一个新分配的Integer对象,它表示String参数所指示的int值;传递的字符串,必须是基本类型的字符串,否则会抛出异常public class IntegerClass { public static void main(String[] arg原创 2021-05-18 12:28:50 · 66 阅读 · 2 评论 -
2021.5.17笔记 System和StringBuilder
System类的常用方法1.currentTimeMillis():返回以毫秒为单位的当前时间2.array copy(Object src, int srcPos, Object dest. int destPos, int length):将数组中指定的数据拷贝到另一个数组中。public class SystemClass { public static void main(String[] args) { demo01(); demo02();原创 2021-05-17 15:03:24 · 65 阅读 · 0 评论 -
2021.5.17笔记 Calendar类
获取对象的方式Calendar类是一个抽象类,提供了很多操作日历字段的方法(YEAR、MONTH、HOUR。。。)由于是抽象类,因此无法直接创建对象使用,可以用getInstance()方法创建对象public class CalendarObj { public static void main(String[] args) { Calendar c = Calendar.getInstance(); //多态,左边父类,右边子类 System.原创 2021-05-17 10:50:57 · 76 阅读 · 0 评论