自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 eclipse超常用快捷键

1.main()方法快键:先输入main,然后 Alt+/2.打印语句快键键:先输入syso,然后 Alt+/3.Alt+Shift+L:抽取本地变量(自动生成new方法前面的内容)4.get、set方法快捷键:Alt+Shift+S,再按r5.无参构造函数快捷键:Alt+Shift+S,再按c6.有参构造函数快捷键:Alt+Shift+S,再按o其它:Home键 快速定位到行首 ,End键 快速定位到行尾Ctrl+z 返回上一步Ctrl+/ 注释掉选中的所有代码,再按取消Ctrl+D

2021-09-15 21:32:18 847

原创 TCP通信

需求:1.客户端:数据来自键盘输入,输入数据是886时,发送结束2.服务端:接收到的数据在控制台显示客户端import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.net.Socket;import java.net.

2021-09-10 15:40:19 95

原创 UDP通信

发送端import java.io.IOException;import java.net.DatagramPacket;import java.net.DatagramSocket;import java.net.InetAddress;public class Send { public static void main(String[] args) throws IOException { //创建发送端对象 DatagramSocket ds=new DatagramSocke

2021-09-10 10:27:51 101

原创 多线程模拟卖票

需求:模拟三个窗口共卖100张票public class SellTicketsDemo { public static void main(String[] args) { SellTickets st=new SellTickets(); Thread t1=new Thread(st,"窗口1"); Thread t2=new Thread(st,"窗口2"); Thread t3=new Thread(st,"窗口3"); t1.start();

2021-09-09 22:04:08 116 1

原创 字节流复制文件

import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;public class c6 { public static void main(String[] args) throws IOException { FileInputStream fis=new FileInputStream("E:

2021-09-09 10:18:30 59

原创 字节流写输入

import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;public class c5 { public static void main(String[] args) throws IOException { //创建文件输出流以指定名称写入数据 FileOutputStream fos=new FileOutputStream("D:\\eclipse

2021-09-09 09:20:46 82

原创 模拟斗地主(洗牌、发牌、看牌)

import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.TreeSet;public class PokerDemo { public static void main(String[] args) { //创建HashMap,键是编号,值是牌 HashMap<Integer,String> hm=new HashMap<In

2021-09-08 17:07:01 108

原创 统计字符串中每个字符出现的次数

import java.util.HashMap;import java.util.Scanner;import java.util.Set;public class c4 { public static void main(String[] args) { //键盘输入一个字符串 Scanner sc=new Scanner(System.in); System.out.println("请输入字符串:"); String line=sc.nextLine(); //创

2021-09-08 11:51:33 124

原创 HashMap集合存储学生对象并遍历

import java.util.HashMap;import java.util.Map.Entry;import java.util.Set;public class MapDemo { public static void main(String[] args) { //创建HashMap集合对象 HashMap<String, Student> hm = new HashMap<String,Student>(); //创建学生对象 Student

2021-09-07 21:54:51 147

原创 不重复的随机数(HashSet集合)

需求:获取10个1~20之间的随机数,要求随机数不能重复,并遍历import java.util.HashSet;import java.util.Random;import java.util.Set;public class c3 { public static void main(String[] args) { //创建Set集合对象 Set<Integer> set=new HashSet<Integer>(); //创建随机数对象 Random

2021-09-07 17:00:23 105

原创 List集合存储学生对象并遍历(三种方法)

测试类import java.util.ArrayList;import java.util.Iterator;import java.util.List; //注意这里不要导错包!public class ListDemo { public static void main(String[] args) { List<Student> list=new ArrayList<Student>(); //创建学生对象 Student s1=new Stud

2021-09-07 12:24:51 368

原创 Collection集合存储学生对象并遍历

测试类public class CollectionDemo { public static void main(String[] args) { Collection<Student> c=new ArrayList<Student>(); //创建学生对象 Student s1=new Student("阿凡达",30); Student s2=new Student("小明",20); Student s3=new Student("小刚",25)

2021-09-06 20:54:10 118

原创 时间工具类

工具类import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;public class DateUtils { private DateUtils() {} //把日期转为指定格式的字符串:format public static String dateToString(Date date,String format) { SimpleDateFormat sdf=new

2021-09-05 16:24:15 72

原创 StringBuilder方法

//append() 添加数据,并返回对象本身。//reverse() 返回相反的字符序列。public class c2 { public static void main(String[] args) { StringBuilder sb=new StringBuilder(); sb.append("hello").append("world"); //链式编程 System.out.println(sb); //输出结果:helloworld

2021-09-05 11:34:36 116

原创 int 和 string 的相互转换

public class c1 { public static void main(String[] args) { //int转换string int number=100; //方法1 String s1=""+ number; System.out.println(s1); //方法2 String s2=String.valueOf(number); System.out.println(s2); System.out.println("---------

2021-09-04 10:46:22 330

原创 学生管理系统

实现效果:1.可以实现添加、删除、修改、遍历操作2.无学生信息时选择 遍历,会提醒先添加学生3.删除、修改操作输入学号不正确时,提醒输入有误import java.util.Scanner;import java.util.ArrayList;public class studentManager { public static void main(String[] args) { ArrayList<student> array=new ArrayList<>(

2021-07-03 15:39:12 267

原创 ArrayList集合存储学生对象并遍历

主要实现:运行程序,通过键盘输入数据(姓名、年龄),然后存储学生对象并遍历。package a1;//主函数import java.util.Scanner;//导包import java.util.ArrayList;public class studentDemo { public static void main(String[] args) { Scanner sc=new Scanner(System.in); ArrayList<student> a=new Ar

2021-07-02 23:45:53 228

原创 猜数字小游戏(java)

import java.util.Scanner;import java.util.Random;public class xx{ public static void main(String[] args){ Random r=new Random(); int b=r.nextInt(100)+1; //随机数范围1-100 while(true){ Scanner sc=new Scanner(System.in); int a=sc.nextInt();

2021-06-30 16:15:02 78

原创 统计三位数中的水仙花数(java)

public class test{ public static void main(String[] args){ int a,b,c,x=0; //统计100-999中间的水仙花数 for(int i=100;i<=999;i++){ a=i/100; b=i/10%10;c=i%10;//a为百位,b为十位,c为个位。 if(a*a*a+b*b*b+c*c*c==i){ System.out.println(i+"是水仙花数"); x+=1; }

2021-06-30 12:00:19 131

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除