public class Test1 {
String name = "asnd";
public static void main(String[] args) {
Test1 test1 = new Test1();
Inner mInner = test1.new Inner();
mInner.print();
}
void show() {
System.out.println("show");
}
public class Inner {
String name = "123";
private void print(){
show();
System.out.println(name);//打印的是123
System.out.println(Test1.this.name);//打印的是asnd
}
}
}
File file = new File("D:/cc.txt") {
@Override
public boolean delete() {
System.out.println("是否删除y/n");
Scanner input = new Scanner(System.in);
String str = input.next();
if (str.equals("y")) {
return super.delete();
}
System.out.println("删除失败");
return false;
}
};
file.delete();
}
new Thread() {
@Override
public void run() {
System.out.println("线程开始!");
try {
Thread.sleep(2000);
System.out.println("线程结束!");
} catch (Exception e) {
e.printStackTrace();
}
super.run();
}
}.start();
for (int i = 0; i < 5; i++) {
final int finali = i;
new Thread() {
public void run() {
System.out.println(finali);
};
}.start();
}
public static void main(String[] args) {
Lam mLam = new Lam();
//第一种实现的方法
mLam.to(new Ligh() {
@Override
public void shin() {
System.out.println("on的第一种方法");
}
});
//第二种实现方法
class MyLam implements Ligh{
@Override
public void shin() {
System.out.println("第二种");
}}
mLam.to(new MyLam());
}
}
interface Ligh {
void shin();
}
class Lam {
public void to(Ligh ligh) {
ligh.shin();
System.out.println("on");
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有