java
码农-小白学习中
这个作者很懒,什么都没留下…
展开
-
java判断是否是回文数
public static void main(String[] args) { int a=0,b=0,c=0,d=0; int f=10000; while(f<100000){ a=f/10000;//获取第一位 b=f%10000/1000;//获取第二位 c=f%100/10;//获取第四位 d=f%10;//获取第五位 if(a==d&c==b){ System.out.println("是回文数:"+f); } f++转载 2020-07-26 18:35:28 · 177 阅读 · 0 评论 -
计算水仙花数
public static void main(String[] args) {int x=100;int a=0,b=0,c=0;while(x<=999){ a=x/100;//获取百位 b=x%100/10;//获取十位 c=x%10;//获取各位 if(x==a*a*a+b*b*b+c*c*c){//判断a,b,c三次方的和是否等于原来的数 System.out.println(x);//如果等于打印 } x++; } } ``...转载 2020-07-26 18:34:34 · 119 阅读 · 0 评论 -
mysql数据库插入中文乱码的解决方案
1.修改数据库字符集为utf-8:ALTER TABLE employee CONVERT TO CHARACTER SET utf82.在连接数据库的后面加上:?useUnicode=true&characterEncoding=UTF-8private static final String URL="jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=UTF-8";private static f原创 2020-07-24 16:57:49 · 94 阅读 · 0 评论 -
java多线程打印0到100
双线程打印0到100public class ThreadDemo4 implements Runnable{ static int num = 0; static String str = "1"; @Override public void run() { try { while (true) { synchronized (str) { if (num原创 2020-07-21 10:35:09 · 400 阅读 · 0 评论 -
数组的增删改查
public static void main(String[] args) { /* Student student=new Student("01","张三",20); Student student1=new Student("02","李四",21); Student student2=new Student("03","王舞",20); StudentManager sm=new StudentManager(); s.原创 2020-07-19 16:46:15 · 87 阅读 · 0 评论 -
数组的排序
冒泡排序public static void sort(int [] num){ for (int i = 0; i <num.length ; i++) { for (int j = i; j <num.length-1 ; j++) { if (num[i]<num[j+1]){ int sum=num[i]; num[i]=num[原创 2020-07-19 16:44:21 · 70 阅读 · 0 评论 -
九九乘法表
public static void cfb(){ for (int i = 1; i <=9; i++) { for (int j = 1; j <=i; j++) { System.out.print(j+"*"+i+"="+j*i+"\t"); } System.out.println(); } } public static void main(String[] args) { cfb(); }``转载 2020-07-19 16:40:37 · 137 阅读 · 0 评论 -
IO流简单的读取和写入
java中通过io流把这个文档里的内容放入另一个文档里 File sreFile=new File("E:\\架包"); String path="E:\\高职\\架包\\"; File uploadFile=new File(path); if (!uploadFile.exists()){ uploadFile.mkdirs(); } File []files=sreFile.listFiles原创 2020-07-19 16:35:57 · 126 阅读 · 0 评论 -
java简单的时间工具类(2)
根据整数型生成日期格式 public String format(int num){ String time=""; String datestr = num+""; SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); try { Date strToDate = sdf.parse(datestr); SimpleDateForma原创 2020-07-19 16:29:39 · 83 阅读 · 0 评论 -
java简单的时间工具类(1)
获取输入日期是星期几 /** * 根据日期获取该日期是星期几 */ public String week(Date date){ SimpleDateFormat sdf=new SimpleDateFormat("EEEE"); String week=sdf.format(date); SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd"); System.原创 2020-07-19 16:27:25 · 81 阅读 · 0 评论 -
计算出生到现在是多少天
根据输入的字符串固定的格式转换为时间格式,在转换为毫秒值与当前日期进行相减,后转换为天数。 public static void main(String[] args) { try { Scanner scanner=new Scanner(System.in); System.out.println("请输入你的出生年月日 格式:xxxx/xx/xx"); String str=scanner.next();原创 2020-07-19 16:14:15 · 1106 阅读 · 0 评论 -
简单扑克牌发牌器
简单的扑克发牌系统public void test(){ List<Integer> list=new ArrayList<>();List<String> color=new ArrayList<>();String []num={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};String []col={"♠","♥","♣","♦"};int sum=0;for (int i原创 2020-07-19 16:05:38 · 1361 阅读 · 0 评论 -
初步了解集合排序 (1)
排序代码块//创建TreeSet比较器MyComparator comparator=new MyComparator();//排序Set<Student> set=new TreeSet<>(comparator);Scanner sc = new Scanner(System.in);for (int i = 0; i <3 ; i++) { System.out.println("输入姓名:"); String name = sc.next()原创 2020-07-19 16:00:17 · 85 阅读 · 0 评论