自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 2020-08-17

Java有参构造方法和无参构造方法1. 定义:编写一个类时没有添加无参构造方法,那么编译器会自动添加无参构造方法;(如果自己添加构造函数,无论有参数或是没参数,默认构造函数都将无效)编写时添加了有参构造方法而未添加无参构造方法,那么编译器只认有参构造方法而不会默认添加无参构造方法!如果需要使用无参构造方法,一定要在类里面添加!2.举例:定义四个类(说明四种情况):类Person1 自己不手动添加任何无参或有参数构造方法 (实例化对象时:编译通过)类Person2 自己添加无参的构造

2020-08-17 15:04:10 451

原创 IO相关内容

IO流的分类网络数据IO本地文件IO特性实质是数据在不同设备间流转只能处理一次 (读取操作后的部分就没有了)使用完毕要关闭 (反向关闭)类型划分输入/输出:Input输入,Output输出字节/字符流:字节流:字节型二进制数据 —— Stream字符流:字符型文本数据 —— Writer输出字符流、Reader输入字符流转换流:字节流和字符流之间需要通过转换流转换 —— InputStreamReader输入转换、OutputStreamWriter输出转换文件流:F

2020-06-09 15:47:23 148

原创 MySQL事务

**事务就是让一组操作要么完美的执行完毕, 要么就不开始执行. **事务的概念:事务指逻辑上的一组操作, 组成这组操作的各个单元, 要么全部成功, 要么全部失败.在不同的环境中, 都可以有事务. 对应在数据库中,就是数据库事务.事务的特性:原子性: 一个事务中所有操作要么都完成, 要么都不完成, 不会在中途结束. 执行过程中如果发生错误, 就会回滚(rollback) 到事务开始前的状态, 就跟没执行一样.一致性: 事务执行前后, 数据要是合法的. 换句话说, 就是数据要完全符合预设的规则(正

2020-05-11 21:07:53 151

原创 MySQL索引

如果把MySQL的表比作一本书,那索引就像这本书的目录,可以帮助我们快速找到想查找的记录.避免出现顺序遍历的情况.索引的用途:避免进行遍历, 优化查询速度(会降低插入和删除速度).索引的工作原理(底层数据结构, B+树):B+树的特点:N叉树结构(树的高度降低, 查询加快);每一层兄弟节点之间相互连通(类似于链表)(遍历起来更方便);叶子节点上储存数据, 非叶子节点用来辅助查找, 不储存数据.B+树的优势:与哈希相比, 可以处理模糊查询的情况;与二叉搜索树相比, 高度更低, 查

2020-05-10 19:40:05 135

原创 实现哈希表代码, 使用哈希桶方式解决哈希冲突

public class MyHashMap_lianxi { static class Node { private int key; private int value; Node next; public Node(int key, int value) { this.key = key; ...

2020-04-29 11:10:58 199 1

原创 MySQL查询练习3

mysql> select * from article;+--------------------+---------------------+| title | create_date |+--------------------+---------------------+| 床前明月光 | 2000-01-09 20:...

2020-04-27 18:14:51 126

原创 MySQL查询练习2

mysql> create table article ( -> name varchar(30), -> create_date timestamp -> );Query OK, 0 rows affected (0.22 sec)mysql> insert into article values -> (...

2020-04-27 17:38:31 176

原创 MySQL查询练习1

mysql> create table student ( -> name varchar(20), -> age int -> );Query OK, 0 rows affected (0.26 sec)mysql> insert into student values -> ('张无忌', 22), -> ...

2020-04-27 16:47:13 125

原创 MySQL插入练习2

mysql> create table book_list ( -> book_name varchar(30), -> author varchar(20), -> book_price decimal(4, 2), -> book_type varchar(30) -> );Query OK, 0 rows affe...

2020-04-27 16:29:26 142

原创 MySQL插入练习1

mysql> insert into goods values ( -> 'xueshengshubao', -> 18.91, -> 101, -> null);Query OK, 1 row affected (0.07 sec)mysql> desc goods;+-------------+------------...

2020-04-26 19:18:40 183

原创 使用MySQL建表3

mysql> create table goods ( -> name varchar(30) comment '商品名称', -> price decimal(20, 8) comment '商品价格', -> inventory int comment '商品库存', -> notice text comment '商品描述' ...

2020-04-23 17:38:02 143

原创 使用MySQL建表2

mysql> create table teacher ( -> name varchar(20) comment '姓名', -> age int comment '年龄', -> stature decimal(4, 4) comment '身高(cm)', -> weight decimal(4, 4) comment '体重(k...

2020-04-23 17:30:31 251

原创 使用MySQL建表1

mysql> create table libraryMenu ( -> BookName varchar(30) comment '书名', -> Author varchar(20) comment '作者', -> Price decimal(12, 4) comment '价格', -> BookType varchar(20)...

2020-04-23 17:17:38 227

原创 String类的常见操作

package String类常见操作;public class StringOperations { public static void main(String[] args) { String str = "Hello Word!"; indexOf(str); replace(str); contains(str)...

2020-03-31 13:48:20 119

原创 Java中compareTo()方法比较字符串详解

中心:String 是字符串,它的比较用compareTo方法,它从第一位开始比较, 如果遇到不同的字符,则马上返回这两个字符的ascii值差值.返回值是int类型1.当两个比较的字符串是英文且长度不等时1)长度短的与长度长的字符一样,则返回的结果是两个长度相减的值a = “hello”;b = “hell”;num = 1;或者a = “h”;b = “hello”;num =...

2020-03-31 13:46:57 453

原创 自定义异常实现登录

实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码. 如果用户名密码出错, 使用自定义异常的方式来处理package 异常登陆;import java.util.Scanner;public class Login { private static String name = "lixing"; private static String password...

2020-03-31 13:02:14 339

原创 JAVA接口和抽象类的特点

接口的特点:1:接口不可实例化,可结合多态进行使用(接口 对象=new 对象())2:接口里的成员属性全部是以 public(公开)、static(静态)、final(最终) 修饰符修饰3:接口里的成员方法全部是以 public(公开)、abstract(抽象) 修饰符修饰4:接口里不能包含普通方法5:子类继承接口必须实现接口里的所有成员方法,除非子类也是抽象类抽象类的特点:1:成员...

2020-03-31 10:47:03 129

原创 两数互换的函数

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>void Exch(int* x, int* y) { int tmp; tmp = *x; *x = *y; *y = tmp; printf("%d, %d", *x, *y);}int main(){ pr...

2020-03-25 17:36:26 290

原创 乘法口诀的函数

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>void Mul(int num) { int i; int j; for (i = 1; i <= num; i++) { for (j = 1; j <= i; j++) { printf("%d*%...

2020-03-25 17:33:53 192

原创 大小写的转化

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>int main() { char c; while ((c = getchar()) != EOF) { if (c >= 'a'&&c <= 'z') { ...

2020-03-25 17:30:41 115

原创 设计一个登陆界面

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main() { int i = 0; for (; i < 3; i++) { printf("请输入密码:"); ...

2020-03-25 17:18:46 444

原创 查找整形有序数组中的数据

#include <stdio.h>#include <stdlib.h>int BinarySearch(int* arr, int size, int toFind) { int left = 0; int right = size - 1; while (left <= right) { int mid = (lef...

2020-03-25 17:15:43 111

原创 猜数字游戏

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <Windows.h>#include <time.h>int Menu(){ printf("=====================\n"); printf("欢迎来到猜数字游...

2020-03-25 16:54:26 414

原创 输入一个数 a,输出"Sn = a + aa + aaa + aaaa + aaaaa"

#include <stdio.h>#include <stdlib.h>int main(){ int a; int Sn = 0; int i; int tmp = 0; scanf_s("%d", &a); for (i = 1; i <= 5; i++) { tmp = tmp * ...

2020-03-25 16:53:07 693

原创 打印一组水仙花数

#include <stdio.h>#include <stdlib.h>int main(){ int i, j, k, n; printf("水仙花数:\n"); for (n = 100; n < 1000; n++) { i = n / 100; j = n / 10 % 10; k...

2020-03-25 16:39:07 94

原创 打印一个菱形

#include <stdio.h>#include <stdlib.h>int main(){ int i; int j; for (i = 1; i < 8; i++) { for (j = 1; j <= 7 - i; j++) { printf(" "); } for (j = 1; j <= 2 * i - 1; j...

2020-03-25 16:37:54 67

原创 求出0-100中9的个数

#include <stdio.h>#include <stdlib.h>int main(){ int i; int count = 0; for (i = 0; i <= 100; i++) { if (i % 10 == 9) { count++; } if (...

2020-03-25 15:38:01 158

原创 求"1-1/2+1/3-1/4+...-1/100"的和

#include <stdio.h>#include <stdlib.h>int main(){ int i; double sum = 0; double tmp = 1; int flag = 1; for (i = 1; i <= 100; i++) { tmp *= flag * 1.0 / i;...

2020-03-25 15:36:16 1274 3

原创 交换两个数组元素

#include <stdio.h>#include <stdlib.h>int main(){ int a[5] = { 1, 2, 3, 4, 5 }; int b[5] = { 11, 22, 33, 44, 55 }; int i, tmp; for (i = 0; i < 5; i++) { tmp = ...

2020-03-25 15:33:20 405 3

原创 求10 个整数中最大值

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>int main(){ int i = 0; int max = 0; int arr[10]; printf("请随机输入10个整数:"); for (i = 0; i < 10; i++)...

2020-03-25 15:31:12 1135

原创 不允许创建临时变量,交换两个数的内容

#include<stdio.h>#include<stdlib.h>int main(){ int a = 5; int b = 10; printf("a=%d,b=%d\n",a,b); a = a + b; b = a - b; a = a - b; printf("a=%d,b=%d\n", a, b);...

2020-03-25 15:30:35 126

原创 给定两个整形变量的值,将两个值的内容进行交换

#include<stdio.h>#include<stdlib.h>int main(){ int a = 1; int b = 2; int c = 0; printf("a=%d,b=%d\n", a, b); c = a; a = b; b = c; printf("a=%d,b=%d\n", a,...

2020-03-25 15:29:55 64

原创 判断1000-2000之间的闰年

#include<stdio.h>#include<stdlib.h>int main(){ int count = 0;//闰年个数 int year;//年份 for (year = 1000; year <= 2000; year++){ //判断是否为世纪闰年 if (year % 400 == 0)...

2020-03-25 15:29:04 135

原创 输出乘法口诀表

#include<stdio.h>#include<stdlib.h>int main(){ int a, b, c; int n = 9; for (a = 1; a <= n; a++){ for (b = 1; b <= a; b++){ c = a*b; //输出...

2020-03-25 15:27:31 113

原创 求出100-200之间的素数

#include<stdio.h>#include<stdlib.h>int main(){ int a, b; for (a = 100; a <= 200; a++){ for (b = 2; b < a; b++){ if (a%b == 0)break; } if...

2020-03-25 15:26:15 156

空空如也

空空如也

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

TA关注的人

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