testinterface.java
来自「JAVA写的一个有关接口的类,希望对初学都有所帮助: QQ:315405572」· Java 代码 · 共 43 行
JAVA
43 行
import java.io.*;
interface Person
{
public void calcAge();
}
class YoungPerson implements Person
{
public void calcAge()
{
int year = 2007;
try
{
InputStreamReader iin = new InputStreamReader(System.in);
BufferedReader bin = new BufferedReader(iin);
System.out.println("请输入一个出生年:");
System.out.flush();
year = Integer.parseInt(bin.readLine());
}
catch(IOException e)
{
}
if(year <= 2007)
{
System.out.print("出生于" + year + "年龄为");
System.out.println( 2007-year);
}
else
{
System.out.println("出生年月不正确");
}
}
}
public class TestInterface
{
public static void main(String[] args)
{
YoungPerson yp = new YoungPerson();
yp.calcAge();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?