文章列表
 
您正在查看 "Java" 分类下的文章

2012-04-01 11:36

file.separator:  Character that separates components of a file path. This is "/" on UNIX and "\" on Windows.

To use this key, you shoud “import java.io.File;”

-------------------------------------------------------------------------------------

More infomation here

http://blogs.atlassian.com/2006/12/how_to_use_file_se

 
2012-03-08 14:31

示例:

public enum EnumTest {
     FRANK("The given name of me"),
     LIU("The family name of me");
     private String context;
     private String getContext(){
    return this.context;
     }
     private EnumTest(S
 
2011-11-22 16:21

Java接口(Interface),是一系列方法的声明,是一些方法特征的集合,一个接口只有方法的特征没有方法的实现,因此这些方法可以在不同的地方被不同的类实现,而这些实现可以具有不同的行为(功能)。

  一.接口含义:

  1.Java接口,Java语言中存在的结构,有特定的语法和结构;2.一个类所具有的方法的特征集合,是一种逻辑上的抽象。

  前者叫做“Java接口”,后者叫做“接口”。

  Java接口本身没有任何实现,因为Java接口不涉及表象,而只

 
2011-11-17 10:53

package generic;

public class DemoHerit_2 {
 public static void main(String args[]) {
  derivedNonGen<String> oa = new derivedNonGen<String>("Value is: ", 100);
  System.out.print(oa.getOb());
  System.out.println(oa.getNum());
 }
}

class nonGen{
 int num;
 
 public nonGen(int num){
  this.num=num;

 
2011-11-17 10:51

package generic;

public class DemoHerit_1 {
 public static void main(String args[]) {
  // 创建子类的对象,它需要传递两个参数,Integer类型给父类,自己使用String类型
  derivedGen<Integer, String> oa = new derivedGen<Integer, String>(100,
    "Value is: ");
  System.out.print(oa.getDob());
  System.out.println(oa.getOb());

 
2011-11-17 10:50

package generic;

public class DemoWildcard {
 public static void main(String args[]) {
  Integer inums[] = { 1, 2, 3, 4, 5 };
  StatsObj<Integer> iobj = new StatsObj<Integer>(inums);
  Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };
  StatsObj<Double> dobj = new StatsObj<Double>(dnums);
  dobj.doSomething(iobj); // iobj和dobj的类型不相同

 
2011-11-17 10:48

package generic;

public class DemoGenIF {
 public static void main(String args[]) {
  Integer inums[] = { 56, 47, 23, 45, 85, 12, 55 };
  Character chs[] = { 'x', 'w', 'z', 'y', 'b', 'o', 'p' };
  MyClass<Integer> iob = new MyClass<Integer>(inums);
  MyClass<Character> cob = new MyClass<Character>(chs);
  System.out.println("Max value in inums: " + iob.max());

 
2011-11-17 10:46

package generic;

public class DemoBounds {
 public static void main(String args[]) {
  Integer inums[] = { 1, 2, 3, 4, 5 };
  Stats<Integer> iobj = new Stats<Integer>(inums);
  System.out.println("平均值为:" + iobj.average1());
  System.out.println("平均值为:" + iobj.average2());
  Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };

 
2011-11-17 10:44

package generic;

public class DemoGenMethods {
 // 定义泛型方法,有一个形式参数用类型参数T来定义
 public static <T> void showGenMsg(T ob, int n) {
  T localOb = ob; // 局部变量也可以用类型参数T来定义
  System.out.println(localOb.getClass().getName());
 }

 public static <T> void showGenMsg(T ob) {
  System.out.println(ob.getClass().getName());

 
2011-11-17 10:43

package generic;

public class DemoGeneric {
 public static void main(String args[]) {
  
  // 声明一个Integer类型的Generic变量
  Generic<Integer> iobj;
  // 创建一个Integer类型的Generic对象
  iobj = new Generic<Integer>(100);
  // 输出它的一些信息
  iobj.showType();

 
   
 
 
文章分类
 
   
 
文章存档
 
     
 
最新文章评论
  

回复prometheus2008:哦
 

回复天使街没有人:你好,我学的计算机。
 

亲 冒昧的问一下你是学什么的?
 

yield()和join()的区别 join方法是,用对象名称调用,在一个线程t2中调用另一个线程t
 

非常好!
   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu