A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 最好的我 中级黑马   /  2015-4-24 22:39  /  344 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

1.
abstract class Name {
   private String name;
   public abstract boolean isStupidName(String name) {}
}
     
2.
public class Something {
   void doSomething () {
       private String s = "";
       int l = s.length();
   }
}

3.
abstract class Something {
   private abstract String doSomething ();
}
   
4.
public class Something {
   public int addOne(final int x) {
       return ++x;
   }
}
   
5.
public class Something {
   public static void main(String[] args) {
       Other o = new Other();
       new Something().addOne(o);
   }
   public void addOne(final Other o) {
       o.i++;
   }
}
class Other {
   public int i;
}
   
6.
class Something {
    int i;
    public void doSomething() {
        System.out.println("i = " + i);
    }
}

7.
class Something {
    final int i;
    public void doSomething() {
        System.out.println("i = " + i);
    }
}
   
8.
public class Something {
     public static void main(String[] args) {
        Something s = new Something();
        System.out.println("s.doSomething() returns " + doSomething());
    }
     public String doSomething() {
        return "Do something ...";
    }
}
   
9.
此处,Something类的文件名叫OtherThing.java
class Something {
    private static void main(String[] something_to_do) {        
        System.out.println("Do something ...");
    }
}

10.
interface  A{
   int x = 0;
}
class B{
   int x =1;
}
class C extends B implements A {
   public void pX(){
      System.out.println(x);
   }
   public static void main(String[] args) {
      new C().pX();
   }
}
     
11.
interface Playable {
    void play();
}
interface Bounceable {
    void play();
}
interface Rollable extends Playable, Bounceable {
    Ball ball = new Ball("PingPang");
}
class Ball implements Rollable {
    private String name;
    public String getName() {
        return name;
    }
    public Ball(String name) {
        this.name = name;        
    }
   public void play() {
        ball = new Ball("Football");
        System.out.println(ball.getName());
    }
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马