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>
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+
}

0 commit comments

Comments
 (0)