
Java
yaoyuan19871221
这个作者很懒,什么都没留下…
展开
-
Java5新特性----静态导入
今天在看书的时候,看见了“静态导入”的这个概念,上网一查才知道是JDK5.0的新特性,真是孤陋寡闻了,所以好好学习了一下。 静态导入,在你自己的类中使用静态导入,可以让你使用其它类中定义的类方法和类变量,而且这些类方法和类变量就像在本地定义的一样。也就是说,静态导入允许您在调用其它类中定义的静态成员时,可以忽略类名。写一段代码理解一下([color=red]代码是最好的教科书[/...2008-09-12 18:29:51 · 111 阅读 · 0 评论 -
SCJP认证试题(十二)
[code="java"]10 public class Hello{11 String title;12 int value;13 public Hello(){14 title += " world";15 }16 public Hello(int value){17 this.value = value;18 title = "Hello...2008-11-28 11:50:21 · 200 阅读 · 0 评论 -
SCJP认证试题(十一)
[code="java"] /** * * @author yaoyuan */10 package com.sun.scjp;11 public class Geodetics{12 public static final double DIAMETER = 12756.32; //kilometers13 }[/code]Which two corr...2008-11-26 10:46:40 · 413 阅读 · 0 评论 -
SCJP认证试题(十)
[code="java"] /** * * @author yaoyuan */1 import java.util.*;2 public class TestSet{3 enum Example{ONE,TWO,THREE}4 public static void main(String[] args){5 Collection coll = ne...2008-11-24 09:23:06 · 161 阅读 · 0 评论 -
SCJP认证试题(九)
Place the correct Code in the Code Sample to achieve the expected results.Expected results:Output :1 2 4 8 16 32Code Sample [code="java"]int[] y = {1,2,4,8,16,32}; System.out.print("Outpu...2008-11-23 15:07:11 · 337 阅读 · 0 评论 -
SCJP认证试题(八)
[code="java"] /** * * @author yaoyuan */11 public static void test(String str){12 if(str == null | str.length() ==){13 System.out.println("String is empty");14 }else{15 System....2008-11-22 11:46:00 · 169 阅读 · 0 评论 -
SCJP认证试题(七)
[code="java"] /** * * @author yaoyuan */11 public static int sum(List list){12 int sum = 0;13 for(Iterator iter = list.iterator();iter.hasNext();){14 int I = ((Integer)iter.next()).i...2008-11-20 15:09:15 · 167 阅读 · 0 评论 -
SCJP认证试题(六)
[code="java"] /** * * @author yaoyuan */public class A{ public void method1(){ B b = new B(); b.method2();5 //more code here }}public class B{ public void method2(){ C ...2008-11-18 11:48:09 · 256 阅读 · 0 评论 -
SCJP认证试题(五)
[code="java"] /** * * @author yaoyuan */public class CertKiller{ int x = 12; public void method(int x){ x += x; System.out.println(x); }}Given the exhibit:21 test t= n...2008-11-18 11:43:57 · 325 阅读 · 0 评论 -
SCJP认证试题(四)
[code="java"] /** * * @author yaoyuan */12 public class Certkiller5{13 public static void main(String[] yahoo){14 for(int x=1;x2008-11-17 09:29:01 · 148 阅读 · 0 评论 -
SCJP认证试题(三)
/** * * @author yaoyuan *//***Which three statements are true?(choose three)**A A final method in class x can be abstract if and only if x is abstract*B A protected method in c...2008-11-14 17:57:42 · 229 阅读 · 0 评论 -
SCJP认证试题(二)
[code="java"] /** * * @author yaoyuan */public class Main implements Runnable{ public void run(){ System.out.print("running"); } public static void main(String[] args){ Thread t...2008-11-12 13:52:04 · 117 阅读 · 0 评论 -
SCJP认证试题
[code="java"] /** * * @author yaoyuan */public class Foo implements Serializable{ public int x, y; public Foo(int x, int y){ this.x = x; this.y = y; ...2008-11-11 16:13:34 · 155 阅读 · 0 评论 -
设计模式--工厂模式
[color=blue]最近在接触设计模式,看了网上的很多资料,自己也练习了一下[/color]工厂模式定义:提供创建对象的接口.工厂模式中有:1. 工厂方法(Factory Method) 2.抽象工厂(Abstract Factory)工厂方法:[code="java"] public class Factory{ pub...原创 2008-09-15 18:52:55 · 100 阅读 · 0 评论 -
SCJP认证试题(十三)
[code="java"]1public class A{2 private int counter = 0;3 4 public static int getInstanceCount(){5 return counter;6 }7 8 public A(){9 counter++;10 }11}Given this code from c...2008-11-29 14:30:26 · 642 阅读 · 0 评论