File tree Expand file tree Collapse file tree
src/test/java/acmr/javacore/basic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## 1 如何跳出嵌套循环?
2+ ``` java
3+ public class Test {
4+ @Test
5+ public void testBreak () {
6+ go:
7+ for (int i = 0 ; i < 100 ; i++ ) {
8+ System . out. println(i);
9+ for (int j = 0 ; j < 100 ; j++ ) {
10+ System . out. println(i + " :" + j);
11+ if (j == 22 ) {
12+ break go;
13+ }
14+ }
15+ }
16+ System . out. println(" go" );
17+ }
18+ }
19+ ```
20+ ## 2 值传递和引用传递
21+ > 值传递:指在调用函数时将实际参数复制一份传递到函数中,这样在函数中如果对参数进行修改,将不会影响到实际参数。
22+ > 引用传递:是指在调用函数时将实际参数的地址直接传递到函数中(的形参),那么在函数中对参数所进行的修改,将影响到实际参数。
23+ > Java 中的基本类型,属于值传递。
24+ > Java 中的引用类型,属于引用传递。
25+ > Java 中的 String 及包装类,属于特殊群体,作为形参时,由于每次赋值都相当于重新创建了对象,因此看起来像值传递,但是其特性已经破坏了,值传递、引用传递的定义。因此他们属于引用传递的定义,却表现为值传递。
26+
27+ ## 3
Original file line number Diff line number Diff line change 22## 1 什么是索引?索引的种类有哪些?
33> 索引:在关系型数据库中,单独的、物理的对数据库表一列或者多列的值进行排序的一种存储结构。
44> 某个表中的一列或者若干列值的集合和相应的指向表中物理标识这些值的数据页的逻辑指针清单。
5- > 通俗的说,索引就相当于图书目录,读者可通过这个目录快速定位阅读内容的页码。
5+ > 通俗的说,索引就相当于图书目录,读者可通过这个目录快速定位阅读内容的页码。
66> 类型:
77> *
Original file line number Diff line number Diff line change 22
33import org .junit .Test ;
44
5+ import java .math .BigDecimal ;
56import java .util .ArrayList ;
67import java .util .List ;
78
@@ -37,6 +38,24 @@ public void testCollection() {
3738
3839 @ Test
3940 public void test () {
41+ double rat = 1.5 ;
42+ System .out .println (new BigDecimal ("0.1" ).add (new BigDecimal ("0.2" )));
43+ int [] test = new int []{1 ,2 ,3 };
44+ "123" .length ();
45+ }
4046
47+ @ Test
48+ public void testBreak () {
49+ go :
50+ for (int i = 0 ; i < 100 ; i ++) {
51+ System .out .println (i );
52+ for (int j = 0 ; j < 100 ; j ++) {
53+ System .out .println (i + ":" + j );
54+ if (j == 22 ) {
55+ break go ;
56+ }
57+ }
58+ }
59+ System .out .println ("go" );
4160 }
4261}
Original file line number Diff line number Diff line change 1+ package acmr .javacore .basic .wtf ;
2+
3+ public class Admin extends User {
4+ public Admin (long id , String name ) {
5+ super (id , name );
6+ }
7+
8+ @ Override
9+ public void main () {
10+ super .main ();
11+ }
12+
13+ public static void staticFun () {
14+ System .out .println ("admin static fun" );
15+ }
16+
17+ public static void main (String [] args ) {
18+ Admin .staticFun ();
19+ Admin admin = new Admin (1 , "guo" );
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package acmr .javacore .basic .wtf ;
2+
3+ public class User {
4+ public long id ;
5+ public String name ;
6+
7+ public User () {
8+ }
9+
10+ public User (long id , String name ) {
11+ this .id = id ;
12+ this .name = name ;
13+ }
14+
15+ public static void main (String [] args ) {
16+ System .out .println (new User ().toString ());
17+ }
18+
19+ public void main () {
20+
21+ }
22+
23+ public static void staticFun () {
24+ System .out .println ("user static fun" );
25+ }
26+
27+ public static void staticFun (int i ) {
28+
29+ }
30+
31+ public long getId () {
32+ return id ;
33+ }
34+
35+ public void setId (long id ) {
36+ this .id = id ;
37+ }
38+
39+ public String getName () {
40+ return name ;
41+ }
42+
43+ public void setName (String name ) {
44+ this .name = name ;
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments