随笔分类 -  Java学习 / JavaSE

1
JavaSE学习过程中一些练习代码
摘要:客户端发出信息 package com.net; import java.io.IOException; import java.io.OutputStream; import java.net.*; //客户端 @SuppressWarnings({"all"}) public class TCP 阅读全文
posted @ 2023-05-04 19:01 Q1uuuu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:package com.thread_; //管程法解决生产者消费者模型 public class PC1 { public static void main(String[] args) { SynContainer container = new SynContainer(); Producto 阅读全文
posted @ 2023-04-29 19:52 Q1uuuu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:package com.thread_; import java.util.Scanner; /* 在main方法中启动两个线程 第1个线程循环随机打印100以内的整数 直到第2个线程从键盘读取了“Q”命令。 */ public class ThreadExercise { public stati 阅读全文
posted @ 2023-04-26 20:44 Q1uuuu 阅读(19) 评论(0) 推荐(0) 编辑
摘要:package com.generic; import org.junit.jupiter.api.Test; import java.util.*; /* 定义个泛型类DAO<T>,在其中定义一个Map成员变量,Map的键为String类型,值为T类型分别创建以下方法: (1) public vo 阅读全文
posted @ 2023-04-23 21:49 Q1uuuu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:package com.generic; import java.util.ArrayList; import java.util.Comparator; /* 定义Employee类 1)该类包含:private成员变量name,sal,birthday,其中 birthday为 MyDate类的 阅读全文
posted @ 2023-04-23 20:18 Q1uuuu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:package com.collection_.map_; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; /* 使用HashMap添加3个员工对象,要求 阅读全文
posted @ 2023-04-14 18:50 Q1uuuu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:package com.collection_.set_; import java.util.HashSet; import java.util.Objects; public class HashSetExercise { public static void main(String[] args 阅读全文
posted @ 2023-04-07 16:04 Q1uuuu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:package com.collection_.list_; public class Book { private String name; private String auther; private double price; public Book(String name, String a 阅读全文
posted @ 2023-04-04 16:49 Q1uuuu 阅读(29) 评论(0) 推荐(0) 编辑
摘要:package com.someexercise; import java.util.Arrays; public class restring { /* 字符反转 将字符串中指定部分进行反转。比如将"abcdef"反转为"aedcbf" 编写方法 public static String reve 阅读全文
posted @ 2023-03-31 22:11 Q1uuuu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:package com.arrays_; import java.util.Arrays; import java.util.Comparator; public class ArraysExercise { public static void main(String[] args) { /* 案 阅读全文
posted @ 2023-03-31 20:33 Q1uuuu 阅读(36) 评论(0) 推荐(0) 编辑
摘要:package com.arrays_; import java.util.Arrays; import java.util.Comparator; public class ArraysSortCustom { public static void main(String[] args) { in 阅读全文
posted @ 2023-03-31 19:23 Q1uuuu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:package com.stringbuffer_; import java.math.BigDecimal; import java.util.Scanner; public class StringBufferExercise01 { public static void main(String 阅读全文
posted @ 2023-03-31 17:56 Q1uuuu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.array; public class ArrayDemo08 { public static void main(String[] args) { //1.创建一个二维数组 11*11 0:没有棋子 1:黑棋 2:白棋 int[][] array1 = new in 阅读全文
posted @ 2023-03-28 17:53 Q1uuuu 阅读(11) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.array; import java.util.Arrays; //冒泡排序 //1.比较数组中两个相邻的元素,如果第一个数大于第二个,交换两者位置 //2.每一次比较,都会产生一个最大或者最小的数组,下一轮就少一次排序 //3.依次循环,直到结束 public cl 阅读全文
posted @ 2023-03-28 17:52 Q1uuuu 阅读(13) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.method; import java.util.Scanner; public class Counter { public static void main(String[] args) { Scanner scanner = new Scanner(System 阅读全文
posted @ 2023-03-27 22:41 Q1uuuu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.struct; public class TestDemo { public static void main(String[] args) { //打印三角形 5行 for (int i = 1; i <= 5; i++) { for (int j = 5; j > 阅读全文
posted @ 2023-03-27 22:39 Q1uuuu 阅读(12) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.struct; //标签的运用,类似于goto public class LabelDemo { public static void main(String[] args) { //打印101~150之间所有的质数 int count = 0; outer:for 阅读全文
posted @ 2023-03-27 22:39 Q1uuuu 阅读(14) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.struct; /* 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*6=6 2*6=12 3*6=18 4*6=24 阅读全文
posted @ 2023-03-27 22:38 Q1uuuu 阅读(276) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.struct; public class ForDemo03 { public static void main(String[] args) { //练习2:用while或for循环输出1-1000之间能被5整除的数,并且每行输出3个 for (int i = 1; 阅读全文
posted @ 2023-03-27 22:37 Q1uuuu 阅读(81) 评论(0) 推荐(0) 编辑
摘要:package com.q1u.struct; public class ForDemo02 { public static void main(String[] args) { //练习1∶计算0到100之间的奇数和偶数的和 int oddsum = 0; int evensum = 0; for 阅读全文
posted @ 2023-03-27 22:36 Q1uuuu 阅读(46) 评论(0) 推荐(0) 编辑

1
点击右上角即可分享
微信分享提示