
Java基础笔记
totome911
这个作者很懒,什么都没留下…
展开
-
Java 基础一些代码练习笔记(多态2)
public class PolyTest5{ /*public void run(BMW bmw) { bmw.run(); } public void run(QQ qq) { qq.run(); }*/ public void run(Car car) { car.run(); } public static void main(String[] ar原创 2011-12-17 09:59:32 · 445 阅读 · 0 评论 -
Java 基础一些代码练习笔记(RandTest)
package com.lee;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.Iterator;import java.util.List;import java.util.Set;import java.util.TreeMa原创 2012-01-08 16:16:59 · 1895 阅读 · 0 评论 -
Java 基础一些代码练习笔记(策略模式)
package com.lee;public interface Strategy{ public int calculate(int a , int b); }package com.lee;public class AddStrategy implements Strategy{ public int calculate(int a, int b) { re原创 2012-01-08 23:12:46 · 510 阅读 · 0 评论 -
Java 基础一些代码练习笔记(Propertise环境变量)
package com.lee;import java.util.Iterator;import java.util.Properties;import java.util.Set;public class PropertiseTest{ public static void main(String[] args) { Properties p = System.getPro原创 2012-01-11 17:23:41 · 551 阅读 · 0 评论 -
Java 基础一些代码练习笔记( GenericFoo<T> 泛型)
package com.lee2;public class GenericFoo{ private T foo; public T getFoo() { return foo; } public void setFoo(T foo) { this.foo = foo; } public static void main(String[] args) {原创 2012-01-12 11:16:06 · 585 阅读 · 0 评论 -
Java 基础一些代码练习笔记( GenericFoo<T> 泛型2)
package com.lee2;public class SimpleCollection{ private T[] objArr; private int index = 0; public SimpleCollection() { objArr = (T[]) new Object[10]; } public SimpleCollection(int capac原创 2012-01-12 16:02:23 · 591 阅读 · 0 评论 -
Java 基础一些代码练习笔记(二分查找)
public class ArraySearchTest{ /*public static int search(int[]array, int value) { for (int i = 0; i < array.length; i++ ) { if (value == array[i]) { return i; } } return -1; }原创 2011-12-29 15:07:04 · 517 阅读 · 0 评论 -
Java 基础一些代码练习笔记(ArrayList)
package com.lee;import java.util.*;public class ArrayListTest1{ public static void main(String[] args) { ArrayList arrayList = new ArrayList(); arrayList.add("hello"); arrayList.add("wo原创 2011-12-30 14:59:10 · 670 阅读 · 0 评论 -
Java 基础一些代码练习笔记(LinkedList)
import java.util.LinkedList;public class LinkListTest1{ public static void main(String[] args) { LinkedList list = new LinkedList(); list.add("F"); list.add("B"); list.add("D"); lis原创 2012-01-02 14:51:47 · 416 阅读 · 0 评论 -
Java 基础一些代码练习笔记( Collectons)
import java.util.Collections;import java.util.Comparator;import java.util.Iterator;import java.util.LinkedList;public class CollectionsTest{ public static void main(String[] args) { LinkedL原创 2012-01-05 21:28:50 · 3417 阅读 · 0 评论 -
Java 基础一些代码练习笔记(HashCode重写)
[com.lee.Student@aa9c3074]package com.lee;import java.util.HashSet;public class SetTest3{ public static void main(String[] args) { HashSet set = new HashSet(); Student s1 = new原创 2012-01-04 17:26:34 · 381 阅读 · 0 评论 -
Java 基础一些代码练习笔记( Interator)
import java.util.HashSet;import java.util.Iterator;public class InteratorTest{ public static void main(String[] args) { HashSet set = new HashSet(); set.add("a"); set.add("b"); set.a原创 2012-01-04 21:58:22 · 486 阅读 · 0 评论 -
Java 基础一些代码练习笔记( TreeSet 排序)
import java.util.Comparator;import java.util.Iterator;import java.util.TreeSet;public class TreeSetTest2{ public static void main(String[] args) { TreeSet set = new TreeSet(new PersonComparat原创 2012-01-05 20:45:37 · 623 阅读 · 0 评论 -
Java 基础一些代码练习笔记(HashMap)
package com.lee;import java.util.HashMap;import java.util.Iterator;import java.util.Set;public class MapTest3{ public static void main(String[] args) { HashMap map = new HashMap(); map原创 2012-01-06 16:43:06 · 728 阅读 · 0 评论 -
Java 基础一些代码练习笔记(队列)
import java.util.LinkedList;public class MyQueue{ private LinkedList list = new LinkedList(); public void put(Object o) { list.addLast(o); } public Object get() { return list.removeF原创 2012-01-03 21:36:55 · 305 阅读 · 0 评论 -
Java 基础一些代码练习笔记(数组复制)
数组复制public class ArrayCopy{ public static void main(String[] args) { int [] a = new int[]{1,2,3,4}; int [] b = new int[4]; System.arraycopy(a,0,b,0,4); /*public static void arraycopy(O原创 2011-12-28 14:35:15 · 360 阅读 · 0 评论 -
Java 基础一些代码练习笔记(继承+接口+多态)
public class Test3{ public static void main(String[] args) { MyClass myClass = new MyClass(); myClass.output(); myClass.output2(); myClass.output3(); }}interface MyInterface{ public原创 2011-12-18 16:08:53 · 1021 阅读 · 0 评论 -
Java 基础一些代码练习笔记(static 关键字)
public class StaticTest{ public static void main(String[] args) { /* MyStatic myStatic = new MyStatic(); MyStatic myStatic2 = new MyStatic(); myStatic.a = 10; System.out.println(myStat原创 2011-12-18 17:11:13 · 430 阅读 · 0 评论 -
Java 基础一些代码练习笔记(抽象类)
public class Test2{ public static void main(String[] args) { Shape shape = new Triangle(10,6); int area = shape.computeArea(); System.out.println("triangle:" + area); shape = new Rectan原创 2011-12-17 11:14:00 · 471 阅读 · 0 评论 -
Java 基础一些代码练习笔记(static 静态代码块)
public class StaticTest{ public static void main(String[] args) { new S(); new S(); }}class P{ static //静态代码块 { System.out.println("P static block"); } public P() { System.out.原创 2011-12-19 22:12:56 · 483 阅读 · 0 评论 -
Java 基础一些代码练习笔记(设计模式-单列模式)
public class SingletonTest{ public static void main(String[] args) { Singleton singleton = Singleton.getInstance(); //通过静态方法直接调用 Singleton singleton2 = Singleton.getInstance(); System.ou原创 2011-12-21 11:21:06 · 526 阅读 · 0 评论 -
Java 基础一些代码练习笔记(Integer)
public class IntegerTest{ public static void main(String[] args) { int a = 10; Integer integer = new Integer(a); int b = integer.intValue(); System.out.println(a == b); }}原创 2011-12-25 16:14:16 · 337 阅读 · 0 评论 -
Java 基础一些代码练习笔记(多态1)
public class PolyTest4{ public static void main (String[] args) { A a = null; if(args[0].equals("1")) { a = new B(); } else if(args[0].equals("2")) { a = new C(); } else if原创 2011-12-15 22:18:48 · 754 阅读 · 0 评论 -
Java 基础一些代码练习笔记(StringBuffer)
public class StringBufferTest{ public static void main(String[] args) { StringBuffer buffer = new StringBuffer(); buffer.append("hello").append(" world").append(" welcome"); String result =原创 2011-12-25 15:40:23 · 403 阅读 · 0 评论 -
Java 基础一些代码练习笔记(object-equals 方法)
public class EqualsTest{ public static void main(String[] args) { Student s1 = new Student("zhangsan"); Student s2 = new Student("zhangsan"); System.out.println(s1 == s2); System.out.prin原创 2011-12-23 15:01:27 · 452 阅读 · 0 评论 -
Java 基础一些代码练习笔记(Array二维数组)
public class ArrayTest5{ public static void main(String[] args) { int[] [] a = new int [][]{{1,2,3},{4},{5,6,7,8}}; for (int i = 0; i < a.length; i++ ) //数组的行 { for (int j = 0; j < a[i].l原创 2011-12-26 20:28:11 · 363 阅读 · 0 评论 -
Java 基础一些代码练习笔记(Array数组)
public class ArrayTest{ public static void main(String[] args) { int[] a = new int[4]; a[0] = 1; a[1] = 2; a[2] = 3; a[3] = 4; System.out.println(a[3]); System.out.println("--------原创 2011-12-26 11:43:13 · 413 阅读 · 0 评论 -
Java 基础一些代码练习笔记(ArrayEquals)
import java.util.Arrays;public class ArrayEquals{ public static boolean isEquals(int[] a , int[] b) { if (a == null || b == null) { return false; } if (a.length != b.length) { re原创 2011-12-27 16:37:43 · 892 阅读 · 0 评论 -
张孝祥 java笔记
多线程:后台线程 Thread tt = new TestThread(); tt.setDaemon(true); //后台线程 tt.start();合并线程: tt.join();静态代码快,线程的同步问题,确保打印票数不会原创 2012-03-07 12:32:19 · 2292 阅读 · 0 评论