Skip to content

Commit d7d05c7

Browse files
JackMrYangJackMrYang
authored andcommitted
提交项目
0 parents  commit d7d05c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2756
-0
lines changed

.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_144"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Javabasic</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8

src/com/classload/ObjectUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.classload;
2+
3+
public class ObjectUtil<E> {
4+
private Class<? extends Object> classO;
5+
public void getClass(Object o) {
6+
classO=o.getClass();
7+
}
8+
9+
}

src/com/fx/Demo01.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.fx;
2+
3+
public class Demo01 {
4+
5+
public static void main(String[] args) {
6+
// 创建不同类型数组: Integer, Double 和 Character
7+
Integer[] intArray = { 1, 2, 3, 4, 5 };
8+
Double[] doubleArray = { 1.1, 2.2, 3.3, 4.4 };
9+
Character[] charArray = { 'H', 'E', 'L', 'L', 'O' };
10+
11+
System.out.println( "整型数组元素为:" );
12+
printArray( intArray ); // 传递一个整型数组
13+
14+
System.out.println( "\n双精度型数组元素为:" );
15+
printArray( doubleArray ); // 传递一个双精度型数组
16+
17+
System.out.println( "\n字符型数组元素为:" );
18+
printArray( charArray ); // 传递一个字符型数组
19+
}
20+
public static <E> void printArray(E[] inputArray) {
21+
for(E element:inputArray) {
22+
System.out.printf("%s ",element);
23+
}
24+
System.out.println();
25+
}
26+
}

src/com/fx/Demo02.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fx;
2+
3+
public class Demo02 {
4+
public static void main(String[] args) {
5+
System.out.printf( "%d, %d 和 %d 中最大的数为 %d\n\n",
6+
3, 4, 5, maximum( 3, 4, 5 ) );
7+
8+
System.out.printf( "%.1f, %.1f 和 %.1f 中最大的数为 %.1f\n\n",
9+
6.6, 8.8, 7.7, maximum( 6.6, 8.8, 7.7 ) );
10+
11+
System.out.printf( "%s, %s 和 %s 中最大的数为 %s\n","pear",
12+
"apple", "orange", maximum( "pear", "apple", "orange" ) );
13+
}
14+
15+
public static <T extends Comparable<T>> T maximum(T x, T y, T z) {
16+
T max=x;
17+
if(y.compareTo(max)>0) {
18+
max=y;
19+
}
20+
if(z.compareTo(max)>0) {
21+
max=z;
22+
}
23+
return max;
24+
}
25+
}

src/com/fx/GenericTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.fx;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class GenericTest {
7+
public static void main(String[] args) {
8+
List<String> name = new ArrayList<String>();
9+
List<Integer> age = new ArrayList<Integer>();
10+
List<Number> number = new ArrayList<Number>();
11+
12+
name.add("icon");
13+
age.add(18);
14+
number.add(314);
15+
16+
//getUperNumber(name);//1
17+
getUperNumber(age);//2
18+
getUperNumber(number);//3
19+
20+
}
21+
22+
public static void getData(List<?> data) {
23+
System.out.println("data :" + data.get(0));
24+
}
25+
26+
public static void getUperNumber(List<? extends Number> data) {
27+
System.out.println("data :" + data.get(0));
28+
}
29+
30+
}

src/com/jz/Demo01.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.jz;
2+
3+
/**
4+
* 进制的转换
5+
* @author Administrator
6+
*
7+
*/
8+
public class Demo01 {
9+
public static void main(String[] args) {
10+
int a=34; //十进制
11+
int b=0b11; //2进制
12+
int c=0xf; //16进制
13+
int d=077; //8进制
14+
System.out.println(a+","+b+","+c+","+d);
15+
}
16+
}

src/com/jz/Demo02.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.jz;
2+
3+
/**
4+
* 数据类型的转换
5+
* @author Administrator
6+
*
7+
*/
8+
public class Demo02 {
9+
public static void main(String[] args) {
10+
int money=2000000000;
11+
int year=20;
12+
int total1=money*year;
13+
long total2=money*year;
14+
long total3=(long)money*year;
15+
System.out.println(total1);
16+
System.out.println(total2);
17+
System.out.println(total3);
18+
19+
//计算一个人70年心跳多少次(假设它每分钟心跳70下)
20+
int times1=70*60*24*365*70;
21+
long times2=70l*60*24*365*70;
22+
System.out.println(times1);
23+
System.out.println(times2);
24+
}
25+
}

src/com/jz/Demo03.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.jz;
2+
3+
/**
4+
* java_jdk7的新特性
5+
* @author Administrator
6+
*
7+
*/
8+
public class Demo03 {
9+
public static void main(String[] args) {
10+
int a=0_0000_0000_0000_0003;
11+
int b=1_342_251;
12+
System.out.println(a);
13+
System.out.println(b);
14+
}
15+
}

src/com/jz/TestOpertor.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.jz;
2+
3+
/**
4+
* 算术运算符
5+
* @author Administrator
6+
*
7+
*/
8+
public class TestOpertor {
9+
public static void main(String[] args) {
10+
int m=8;
11+
int n=4;
12+
System.out.println(m&n);
13+
System.out.println(m|n);
14+
System.out.println(~m);
15+
System.out.println(m^n);
16+
17+
int a1=3*2*2;
18+
int a2=3<<2;
19+
int a3=3<<3;
20+
int a4=24>>2;
21+
System.out.println(a1);
22+
System.out.println(a2);
23+
System.out.println(a3);
24+
System.out.println(a4);
25+
}
26+
}

src/com/person/io/FileIoDemo01.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.person.io;
2+
3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.io.IOException;
6+
7+
public class FileIoDemo01 {
8+
public static void main(String[] args) throws IOException {
9+
File file=new File("E:\\c.txt");
10+
FileInputStream is=new FileInputStream(file);
11+
byte[] b=new byte[(int) file.length()];
12+
is.read(b);
13+
System.out.println(new String(b));
14+
is.close();
15+
}
16+
}

src/com/person/math/sort/Mpsort.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.person.math.sort;
2+
3+
public class Mpsort {
4+
public static void sort(int[] data) {
5+
int length=data.length;
6+
if(length<=1) return;
7+
for(int i=0;i<length;i++) {
8+
for(int j=0;j<length-1-i;j++) {
9+
if(data[j]>data[j+1]) {
10+
int temp=data[j+1];
11+
data[j+1]=data[j];
12+
data[j]=temp;
13+
}
14+
}
15+
}
16+
}
17+
public static int serachHalf(int[] arr,int target) {
18+
int left=0,right=arr.length-1;
19+
while(left<=right) {
20+
int middle=(left+right)/2;
21+
if(arr[middle]==target) {
22+
return middle;
23+
}else if(target<arr[middle]) {
24+
right=middle-1;
25+
}else {
26+
left=middle+1;
27+
}
28+
}
29+
return -1;
30+
}
31+
public static void main(String[] args) {
32+
int data[]= {1,4,5,8,2,41,36,21};
33+
selectsort(data);
34+
System.out.println(serachHalf(data, 8));
35+
for(int i:data)
36+
System.out.print(i+",");
37+
}
38+
public static void insertsort(int[] data) {
39+
int length=data.length;
40+
if(length<=1) return;
41+
for(int i=1;i<length;i++) {
42+
int j=i-1;
43+
int key=data[i];
44+
while(j>=0&&key<data[j]) {
45+
data[j+1]=data[j];
46+
j--;
47+
}
48+
data[j+1]=key;
49+
}
50+
}
51+
52+
public static void selectsort(int[] data) {
53+
int length=data.length;
54+
if(length<=1) return;
55+
for(int i=0;i<length;i++) {
56+
int min=i;
57+
for(int j=length-1;j>i;j--) {
58+
if(data[j]<data[min])
59+
min=j;
60+
}
61+
int temp=data[i];
62+
data[i]=data[min];
63+
data[min]=temp;
64+
}
65+
}
66+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.person.test;
2+
3+
import java.util.ArrayList;
4+
import java.util.Iterator;
5+
import java.util.List;
6+
7+
public class ArrayListTest {
8+
public static void main(String[] args) {
9+
List<String> nameList=new ArrayList<>();
10+
nameList.add("java");
11+
nameList.add("java");
12+
nameList.add("javc");
13+
nameList.add("javd");
14+
nameList.add("jvm");
15+
removeReList(nameList);
16+
//nameList.remove("java");
17+
Iterator<String> it=nameList.iterator();
18+
while(it.hasNext()) {
19+
System.out.println(it.next());
20+
}
21+
/*for(String s:nameList) {
22+
System.out.println(s);
23+
}*/
24+
}
25+
public static void removeReList(List list) {
26+
/*for(int i=list.size()-1;i>=0;i--) {
27+
if("java".equals(list.get(i))) {
28+
list.remove(i);
29+
}
30+
}*/
31+
for(int i=0;i<list.size();i++) {
32+
if("java".equals(list.get(i))) {
33+
list.remove(i);
34+
i--;
35+
}
36+
}
37+
}
38+
}

src/com/person/test/Demo01.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.person.test;
2+
3+
public class Demo01 {
4+
public static void main(String[] args) {
5+
String[] s="sbc".split(",");
6+
System.out.println(s[0]);
7+
}
8+
}

src/com/person/test/Demo02.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.person.test;
2+
3+
public class Demo02 {
4+
public static void main(String[] args) {
5+
System.out.println("第一个月兔子的对数:"+1);
6+
System.out.println("第二个月兔子的对数:"+1);
7+
int f1=1,f2=1,f,M=24;
8+
for(int i=3;i<=M;i++) {
9+
f=f1+f2;
10+
f1=f2;
11+
f2=f;
12+
System.out.println("第个"+i+"月兔子的对数:"+f2);
13+
}
14+
}
15+
}

src/com/person/test/ObjectTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.person.test;
2+
3+
public class ObjectTest {
4+
public static int i=100;
5+
public static void go() {
6+
i++;
7+
}
8+
public static void main(String[] args) {
9+
go();
10+
System.out.println(i);
11+
i++;
12+
ObjectTest.i++;
13+
System.out.println(i);
14+
new ObjectTest().i--;
15+
System.out.println(i);
16+
}
17+
}

0 commit comments

Comments
 (0)