本帖最后由 张甲甲 于 2013-6-4 14:22 编辑
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();
}
}
|
|