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)大端模式:
低地址 -----------------> 高地址2)小端模式:
低地址 ------------------> 高地址
内存地址 | 小端模式存放内容 | 大端模式存放内容 |
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关闭。静态变量方法若在系统中定义太多,会占用大量的资源,最后造成内存溢出,所以静态方法不能滥用。
输出:
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的递归查询
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
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的行转列
实现效果如下:
13Spring的注解有哪些?
@Controller @Service @Autowired @RequestMapping @RequestParam @PathVariable @ModelAttribute @ResponseBody