Skip to content

Commit 353d6ed

Browse files
java虚拟机开始学习
1 parent 3387621 commit 353d6ed

10 files changed

Lines changed: 149 additions & 1 deletion

File tree

src/main/java/com/basics/JucTest/CallableTest/CallableDemon.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ public Integer call() throws Exception {
2020
return sum;
2121
}
2222

23-
2423
}

src/main/java/com/basics/JucTest/Final/RunnableTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static void main(String[] args) {
2525
});
2626
}
2727

28+
2829
executorService.shutdown();
2930
}
3031
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.jdk8.lmb;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.function.Consumer;
6+
7+
/**
8+
* @ClassName TestOne
9+
* @Despacito TODO
10+
* @Author chenzhuo
11+
* @Version 1.0
12+
**/
13+
public class TestOne {
14+
public static void main(String[] args) {
15+
List<Integer> list = new ArrayList<>();
16+
list.add(1);
17+
list.add(2);
18+
list.add(3);
19+
list.add(4);
20+
Runnable rr;
21+
22+
list.forEach(new Consumer<Integer>() {
23+
@Override
24+
public void accept(Integer integer) {
25+
26+
}
27+
});
28+
}
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.jdk8.lmb.lam_interface;
2+
/**
3+
* 函数式接口
4+
*/
5+
@FunctionalInterface
6+
public interface LamInterfaceTest {
7+
String getString();
8+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.jdk8.lmb.lam_interface.impl;
2+
3+
4+
import com.jdk8.lmb.lam_interface.LamInterfaceTest;
5+
import com.sun.org.apache.regexp.internal.RE;
6+
7+
import java.util.concurrent.Callable;
8+
9+
/**
10+
* @ClassName InterFaceTest
11+
* @Despacito TODO
12+
* @Author chenzhuo
13+
* @Version 1.0
14+
**/
15+
public class InterFaceTest {
16+
public static void main(String[] args) {
17+
18+
Callable callable = ()->{
19+
return "" ;
20+
};
21+
LamInterfaceTest interfaceTest = ()-> {
22+
System.out.println("hello : " + System.currentTimeMillis());
23+
return "hello Word";
24+
};
25+
String string = interfaceTest.getString();
26+
System.out.println("string:"+string );
27+
}
28+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.jdk8.lmb.lam_interface.impl;
2+
3+
import com.jdk8.lmb.lam_interface.LamInterfaceTest;
4+
5+
/**
6+
* @ClassName InterfaceImpl
7+
* @Despacito TODO
8+
* @Author chenzhuo
9+
* @Version 1.0
10+
**/
11+
public class InterfaceImpl implements LamInterfaceTest {
12+
13+
public String string ;
14+
15+
16+
public void setString(String string) {
17+
this.string = string;
18+
}
19+
20+
public InterfaceImpl(){
21+
22+
}
23+
24+
public InterfaceImpl(LamInterfaceTest interfaceTest) {
25+
interfaceTest.getString();
26+
}
27+
28+
public String getString() {
29+
return "hello Word";
30+
}
31+
32+
public String getString(String s) {
33+
return s;
34+
}
35+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.jdk8.lmb;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import javax.swing.*;
7+
8+
/**
9+
* @ClassName lmb
10+
* @Despacito TODO
11+
* @Author chenzhuo
12+
* @Version 1.0
13+
**/
14+
public class lmb {
15+
private static Logger logger =
16+
LoggerFactory.getLogger(lmb.class);
17+
public static void main(String[] args) {
18+
JFrame frame = new JFrame("lm");
19+
JButton jButton = new JButton("s");
20+
jButton.addActionListener(event->
21+
System.out.println("e" + event.getModifiers())
22+
);
23+
frame.add(jButton);
24+
frame.pack();
25+
frame.setVisible(true);
26+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* 兰八达表达式
3+
* 函数式接口:
4+
* 1.如果一個接口只有一个抽象方法,那麼他就是一個函数式接口
5+
* Note that instances of functional interfaces can be created with
6+
* lambda expressions, method references, or constructor references.
7+
* 函数接口的实例,可以使用lambda表达式和方法引用 或者构造方式引用来创建函数式接口的实例
8+
* 2.如果在接口上声明了FunctionalInterface注解,那么编译器就会按函数式接口的定义来要求接口
9+
* 3.如果一个接口有且只有一个抽象方,但是我们并没有声明FunctionalInterface注解,jvm也会默认认为他是一个函数
10+
*/
11+
package com.jdk8.lmb;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* jdk8的特性
3+
* 学习已经及兼容
4+
*/
5+
package com.jdk8;

src/main/java/com/sun/jvm/ClassLocader/VmClassLoader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.basics.ClassLoaderTest.ClassLoaderLoadClass;
44

5+
import java.util.concurrent.FutureTask;
6+
57
/**
68
* @ClassName VmClassLoader
79
* @Despacito TODO 学习jvm
@@ -28,6 +30,8 @@ public class VmClassLoader {
2830
public static void main(String[] args) {
2931
/* ClassLoader classLoader = ClassLoader.getSystemClassLoader();
3032
classLoader.loadClass();*/
33+
Class clazz ;
34+
3135
Singer singer = Singer.getInstance();
3236
System.out.println("count1:" + singer.count1);
3337
System.out.println("count2:" + singer.count2);

0 commit comments

Comments
 (0)