随笔分类 -  java基础

摘要:this this 表示当前对象 super 1.子类重写父类的方法 public class B extends A{ private String nameB="B"; @Override public void getName() { System.out.println("子类"+nameB 阅读全文
posted @ 2021-10-18 22:12 clown-lan 阅读(47) 评论(0) 推荐(0)
摘要:内部类 编译后生成独立的字节码文件 内部类可以之间访问外部类的私有成员 疑问 访问修饰符 default (即默认,什么也不写): 在同一包内可见,不使用任何修饰符。使用对象:类、接口、变量、方法。 private : 在同一类内可见。使用对象:变量、方法。 注意:不能修饰类(外部类) public 阅读全文
posted @ 2021-10-18 21:32 clown-lan 阅读(80) 评论(0) 推荐(0)
摘要:连接数据库 启动MySQL net start mysql 连接数据库语句 : mysql -h 服务器主机地址 -u 用户名 -p 用户密码 -p后面不能加空格,会被当做密码的内容 几个基本的数据库操作命令 : show databases; 显示所有数据库 use databasename;打开 阅读全文
posted @ 2021-10-10 10:31 clown-lan 阅读(53) 评论(0) 推荐(0)
摘要:mysql 3.7 1、下载后得到zip压缩包. 2、解压到自己想要安装到的目录,假设解压到D:\Environment\mysql-5.7.19 3、添加环境变量:我的电脑->属性->高级->环境变量 选择PATH,在其后面添加: 你的mysql 安装文件下面的bin文件夹 4、编辑 my.ini 阅读全文
posted @ 2021-10-10 10:20 clown-lan 阅读(54) 评论(0) 推荐(0)
摘要:异常 package error;​public class Test { public static void main(String[] args) { int a=1,b=0; try { System.out.println(a/b); } catch (Exception e) { Sys 阅读全文
posted @ 2021-10-08 20:54 clown-lan 阅读(38) 评论(0) 推荐(0)
摘要:instanceof 抽象类 package oop.demo8;​//约束,子类帮助实现,不能new这个对象//抽象方法必须在抽象类中,抽象类中可以有普通方法abstract public class Demo8 { abstract public void something();​} 接口 p 阅读全文
posted @ 2021-10-08 19:32 clown-lan 阅读(49) 评论(0) 推荐(0)
摘要:多态 package oop.demo7;​public class Demo7 { public static void main(String[] args) { //一个对象的实际类型是确定的 new Student()​ Student student=new Student(); //St 阅读全文
posted @ 2021-10-08 17:30 clown-lan 阅读(32) 评论(0) 推荐(0)
摘要:package oop.demo4;​import oop.demo4.Student;​public class Demo4 { public static void main(String[] args) { Student student=new Student(); student.getN 阅读全文
posted @ 2021-10-07 22:23 clown-lan 阅读(18) 评论(0) 推荐(0)
摘要:package oop.demo3;​public class Demo3 { public static void main(String[] args) { Person person=new Person(); Person person1=new Person("book"); System 阅读全文
posted @ 2021-10-07 21:40 clown-lan 阅读(42) 评论(0) 推荐(0)
摘要:静态与非静态方法 package oop;​public class Demo { public static void main(String[] args) { Demo.a(); new Demo().b(); } public static void a(){ System.out.prin 阅读全文
posted @ 2021-10-07 21:26 clown-lan 阅读(54) 评论(0) 推荐(0)
摘要:堆 初始化 package array;​public class Demo { public static void main(String[] args) { //动态初始化, int[] num=new int[10]; System.out.println(num[0]); //0 //静态 阅读全文
posted @ 2021-10-06 21:44 clown-lan 阅读(13) 评论(0) 推荐(0)
摘要:方法 package method;​public class Demo1 { public static void main(String[] args) { int sum=add(1,2); System.out.println(sum);​ } public static int add(i 阅读全文
posted @ 2021-10-06 20:46 clown-lan 阅读(66) 评论(0) 推荐(0)
摘要:增强for package base;​public class Demo8 { public static void main(String[] args) { int[] numbers={1,2,3,4,5}; for(int i=0;i<5;i++){ System.out.println( 阅读全文
posted @ 2021-10-06 19:37 clown-lan 阅读(45) 评论(0) 推荐(0)
摘要:switch package base;​public class Demo7 { public static void main(String[] args) { String str="中国"; switch (str){ case "中国": System.out.println("中国"); 阅读全文
posted @ 2021-10-06 10:44 clown-lan 阅读(43) 评论(0) 推荐(0)
摘要:Scanner package base;​import java.util.Scanner;​public class Demo5 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); 阅读全文
posted @ 2021-10-06 10:43 clown-lan 阅读(42) 评论(0) 推荐(0)
摘要:输出时连接符+ public class Demo4 { public static void main(String[] args) { int a=10; int b=12; System.out.println(""+a+b); //1012 System.out.println(a+b+"" 阅读全文
posted @ 2021-10-06 09:56 clown-lan 阅读(31) 评论(0) 推荐(0)
摘要:运算符优先级 一级 二级 . [] () ! ~ ++ -- 三级 4级 5级 % * / + - << >> 6级 7级 < > <= > != 8级 9级 10级 & ^ | 11级 12级 13级 && || ?: 14级 = += -= 从右向左 二级 13级 14级 阅读全文
posted @ 2021-10-06 09:30 clown-lan 阅读(40) 评论(0) 推荐(0)
摘要:ctrl+d 复制当前行到下一行 运算时 short+byte=int 自加 int a=3;int b=a++;int c=++a;//a=5,b=3,c=5 幂运算 double pow=Math.pow(3,2); 短路运算 int c=3;boolean b=(c>4)&&(c++<4);/ 阅读全文
posted @ 2021-10-06 09:18 clown-lan 阅读(72) 评论(0) 推荐(0)
摘要:命名规则 常量 大写字母 _ 类名 首字母大写 首字母小写 驼峰原则 作用域 public class Demo3 {​ //类变量 //修饰符,不存在先后顺序 static final char PI='a'; final static char PI2='b';​ //实例变量 从属于对象 // 阅读全文
posted @ 2021-10-05 22:20 clown-lan 阅读(60) 评论(0) 推荐(0)
摘要:Demo2 public class Demo2 { public static void main(String[] args) { int a=10; //10进制-10 int b=010; //8进制-8 int c=0x10; //16进制-16 System.out.println(a) 阅读全文
posted @ 2021-10-05 21:37 clown-lan 阅读(49) 评论(0) 推荐(0)