1创建一个软链接
eg:ln -s /bin/hello.sh /usr/local/bin/hello
在/usr/local/bin/hello下创建一个/bin/hello.sh的软链接,访问/usr/local/bin/hello即访问/bin/hello.sh
2软链接和硬链接的区别
大端模式,是指数据的高位字节保存在内存的低地址中,而数据的低位字节保存在内存的高地址中
小端模式,是指数据的高位字节保存在内存的高地址中,而数据的低位字节保存在内存的低地址中
eg:
16bit宽的数字0x12 34 56 78在内存中的表示形式为:
1)大端模式:
低地址 -----------------> 高地址0x12 | 0x34 | 0x56 | 0x78
2)小端模式:
低地址 ------------------> 高地址0x78 | 0x56 | 0x34 | 0x12
内存地址 | 小端模式存放内容 | 大端模式存放内容 |
0x4000 | 0x78 | 0x12 |
0x4001 | 0x56 | 0x34 |
0x4002 | 0x34 | 0x56 |
0x4003 | 0x12 | 0x78 |
IPV6:6个字节,共48位
IP地址=网络位+主机位
113=01110001
网络位:27
主机位:32-27=5
子网掩码:255.255.255.11100000=255.255.255.224
主机数=2的5次方-2(减去网络地址和广播地址)
网络地址=10.117.205.01100000=10.117.205.96
广播地址=10.117.205.01111111=10.117.205.127
地址范围=10.117.205.97-10.117.205.126
(2)ip=10.158.79.53,子网掩码=255.255.248.0,求网络位、主机位、主机数、网络地址、广播地址
248=11111000
79=01001111
网络位=21
主机位=11
主机数=2的11次方-2
网络地址=10.158.01001000.0=10.158.72.0
广播地址=10.158.01001111.255=10.158.79.255
(3)子网掩码为255.255.248.0,求主机数
248=11111000
主机数=2的11次方-2
6关于Java的静态有哪些?
静态类、静态变量、静态方法、静态代码块(1)静态变量:由static修饰,在JVM中,静态变量的加载顺序在对象之前,因此静态变量不依附于对象存在,可以在不实例化类的情况下直接使用静态变量,如下代码所示。
public class StaticTest {
static int a = 13;
int b = 14;
public static void main(String[] args) {
int c = StaticTest.a;
System.out.println(c);
}
}
静态变量属于类,不属于类中任何一个对象,因此静态变量又叫做类变量,一个类不管创建多少个对象(对象是类的一个实例),静态变量在内存中有且仅有一个。
(2)实例变量:必须依附于对象存在,只有实例化类后才可以使用此类中的实例变量。
public class StaticTest {
static int a = 13;
int b = 14;
public static void main(String[] args) {
int d = new StaticTest().b;
System.out.println(d);
}
}
(3)静态方法:方法用static关键字修饰,静态方法与静态成员变量一样,属于类本身,在类装载的时候被装载到内存,不自动进行销毁,会一直存在于内存中,直到JVM关闭。使用时也是不需要实例化类,能够直接使用。静态方法无法被重写。
public class StaticTest {
public static void MyStatic(){
System.out.println("这是StaticTest的一个静态方法");
}
public static void main(String[] args) {
StaticTest.MyStatic();
}
}
需要注意的是:在静态方法中只能访问类中的静态成员跟静态方法,不能直接访问类中的实例变量跟实例方法,原因是静态方法在JVM中的加载顺序也在对象之前,直接使用实例变量跟实例方法的话,可能实例变量跟实例方法所依附的对象并没有被创建,会导致无法找到所使用的实例变量跟实例方法。
(4).实例化方法:属于实例对象,实例化后才会分配内存,必须通过类的实例来引用。不会常驻内存,当实例对象被JVM 回收之后,也跟着消失。
public class StaticTest {
public void MyMethod(){
System.out.println("这是StaticTest的一个实例方法");
}
public static void main(String[] args) {
new StaticTest().MyMethod();
}
}
附加:
1.线程安全:静态方法静态变量是线程不安全的。非静态方法非静态变量是线程安全的。
2.静态方法静态方法是类加载时一起加载到JVM中,是常驻内存直到JVM关闭。静态变量方法若在系统中定义太多,会占用大量的资源,最后造成内存溢出,所以静态方法不能滥用。
- public class HelloA {
- //构造方法
- public HelloA(){
- System.out.println("Hello A!父类构造方法");
- }
- //非静态代码块
- {
- System.out.println("i'm A class.父类非静态代码块");
- }
- //静态代码块
- static{
- System.out.println("static A 父类静态代码块");
- }
- }
- public class HelloB extends HelloA {
- //构造方法
- public HelloB(){
- System.out.println("Hello B! 构造方法");
- }
- //非静态代码块
- {
- System.out.println("i'm B class.非静态代码块");
- }
- //静态代码块
- static{
- System.out.println("static B 静态代码块");
- }
- public static void main(String[] args) {
- System.out.println("---start---");
- new HelloB();
- new HelloB();
- System.out.println("---end---");
- }
- }
- static A 父类静态代码块
- static B 静态代码块
- ---start---
- i'm A class.父类非静态代码块
- HelloA!父类构造方法
- i'm B class.非静态代码块
- HelloB! 构造方法
- i'm A class.父类非静态代码块
- HelloA!父类构造方法
- i'm B class.非静态代码块
- HelloB! 构造方法
- ---end---
- public class SuperAndSub {
- public static void main(String[] args) {
- Sub s3 = new Sub();
- }
- }
- class Super {
- static int a = getA();
- static {
- System.out.println("加载Super的静态块");
- }
- int b = getB();
- {
- System.out.println("加载Super的普通块");
- }
- Super() {
- System.out.println("加载Super的构造器");
- }
- static int getA() {
- System.out.println("加载Super的静态变量");
- return 1;
- }
- static int getB() {
- System.out.println("加载Super的实例变量");
- return 2;
- }
- }
- class Sub extends Super {
- static int c = getC();
- static {
- System.out.println("加载Sub的静态块");
- }
- int d = getD();
- {
- System.out.println("加载Sub的普通块");
- }
- Sub() {
- System.out.println("加载Sub的构造器");
- }
- static int getC() {
- System.out.println("加载Sub的静态变量");
- return 1;
- }
- static int getD() {
- System.out.println("加载Sub的实例变量");
- return 2;
- }
- }
输出:
- 加载Super的静态变量
- 加载Super的静态块
- 加载Sub的静态变量
- 加载Sub的静态块
- 加载Super的实例变量
- 加载Super的普通块
- 加载Super的构造器
- 加载Sub的实例变量
- 加载Sub的普通块
- 加载Sub的构造器
1.父类代码
1 package com.hafiz.zhang; 2 3 public class Fu 4 { 5 private int i = print("this is father common variable"); 6 private static int j = print("this is father static variable"); 7 static{ 8 System.out.println("this is father static code block"); 9 } 10 { 11 System.out.println("this is father common code block"); 12 } 13 public Fu(){ 14 System.out.println("this is father constructor"); 15 } 16 17 static int print(String str){ 18 System.out.println(str); 19 return 2; 20 } 21 }
2.子类代码
1 package com.hafiz.zhang; 2 3 public class Zi extends Fu 4 { 5 private int l = print("this is son common variable"); 6 private static int m = print("this is son stati variable"); 7 static{ 8 System.out.println("this is son static code block"); 9 } 10 { 11 System.out.println("this is son common code block"); 12 } 13 public Zi(){ 14 System.out.println("this is son constructor"); 15 } 16 public static void main(String[] args) { 17 new Zi(); 18 } 19 }
最后运行结果为:
下面让我们修改一下两个类中静态代码块和静态成员变量的位置并重新运行
3.修改后的父类代码
1 package com.hafiz.zhang; 2 3 public class Fu 4 { 5 static{ 6 System.out.println("this is father static code block"); 7 } 8 { 9 System.out.println("this is father common code block"); 10 } 11 public Fu(){ 12 System.out.println("this is father constructor"); 13 } 14 15 static int print(String str){ 16 System.out.println(str); 17 return 2; 18 } 19 private int i = print("this is father common variable"); 20 private static int j = print("this is father static variable"); 21 }
4.修改后的子类代码
1 package com.hafiz.zhang; 2 3 public class Zi extends Fu 4 { 5 static{ 6 System.out.println("this is son static code block"); 7 } 8 { 9 System.out.println("this is son common code block"); 10 } 11 public Zi(){ 12 System.out.println("this is son constructor"); 13 } 14 public static void main(String[] args) { 15 new Zi(); 16 } 17 private int l = print("this is son common variable"); 18 private static int m = print("this is son stati variable"); 19 }
修改后的运行结果:
List:有序可重复,有ArrayList、Vector、LinkedList
Map:键值对 key/value,有HashMap、HashTable、CocurrentHashMap
Set:无序不可重复,有HashSet、LinkedHashSet、TreeSet
8String类的方法有哪些?
代码:
结果如下:
9Oracle的递归查询
- create table tb_menu(
- id number(10) not null, --主键id
- title varchar2(50), --标题
- parent number(10) --parent id
- )
- insert into tb_menu(id, title, parent) values(1, '父菜单1',null);
- insert into tb_menu(id, title, parent) values(2, '父菜单2',null);
- insert into tb_menu(id, title, parent) values(6, '一级菜单6',1);
- insert into tb_menu(id, title, parent) values(7, '一级菜单7',1);
- insert into tb_menu(id, title, parent) values(8, '一级菜单8',1);
- insert into tb_menu(id, title, parent) values(9, '一级菜单9',2);
- insert into tb_menu(id, title, parent) values(10, '二级菜单21',6);
- insert into tb_menu(id, title, parent) values(11, '二级菜单22',6);
1)、查找树中的所有顶级父节点(辈份最长的人)
select * from tb_menu m where m.parent is null;
2)、查找一个节点的直属子节点(所有儿子)
select * from tb_menu m where m.parent=1;
3)、查找一个节点的所有直属子节点(所有后代)。
实在难以理解,可以这样记忆,prior放在哪里,就找谁,这里放在id,就是找的后代。
select * from tb_menu m start with m.id=1 connect by m.parent=prior m.id;
4)、查找一个节点的直属父节点(父亲)
select c.id, c.title, p.id parent_id, p.title parent_title from tb_menu c, tb_menu p where c.parent=p.id and c.id=6
5)、查找一个节点的所有直属父节点(祖宗)。
select * from tb_menu m start with m.id=38 connect by prior m.parent=m.id;
10java 中有可能出现 i + 1 < i 的情况吗?为什么
存在的,i+1<i,假设i是int类型,那么当i=2^32-1时,i+1数据溢出变成负数,就达成了条件i+1<i,其他类型同理
11Java中i++和++i的区别
(1)
int i=1,a=0;
System.out.println("a=i++===> "+(a=i++));//1 a=i i++
//System.out.println("a=++i===> "+(a=++i));//2 i++ a=i
(2)
int y=0; //注意"="是赋值,"=="才是相等
y=++y; //y==0,++y==y+1; 结果y=++y == y+1 == 0+1 ==1
y=++y; //y==1,++y==y+1; 结果y=++y == y+1 == 1+1 ==2
y=++y; //y==2,++y==y+1; 结果y=++y == y+1 == 2+1 ==3
System.out.println("y="+y); //3
int i =0; //i==0
i=i++; //i=i++;的操作可能相当于以下三步操作:①把变量i的值取出来,放在一个临时变量temp里;②把变量i的值进行自加操作;③把temp的值赋值给i
i=i++;
i=i++;
System.out.println("i="+i); //0
12oracle的行转列
实现效果如下:
- select t.user_name as 姓名,
- MAX(decode(t.course,'语文',score,null)) as 语文,
- MAX(decode(t.course,'数学',score,null)) as 数学,
- MAX(decode(t.course,'英语',score,null)) as 英语
- from RowToCol t group by t.user_name order by t.user_name
13Spring的注解有哪些?
@Controller @Service @Autowired @RequestMapping @RequestParam @PathVariable @ModelAttribute @ResponseBody